Here is the error message I receive when compiling ...
Ld /Users/ilia3546/Library/Developer/Xcode/DerivedData/MasterDetail-fhgogwnbpzovbtaskgecptdnvgjs/Build/Products/Debug-iphonesimulator/MasterDetail.app/MasterDetail normal i386
cd /Users/ilia3546/Проекты/iDecide
setenv IPHONEOS_DEPLOYMENT_TARGET 5.0
setenv PATH "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch i386 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.0.sdk -L/Users/ilia3546/Library/Developer/Xcode/DerivedData/MasterDetail-fhgogwnbpzovbtaskgecptdnvgjs/Build/Products/Debug-iphonesimulator -F/Users/ilia3546/Library/Developer/Xcode/DerivedData/MasterDetail-fhgogwnbpzovbtaskgecptdnvgjs/Build/Products/Debug-iphonesimulator -filelist /Users/ilia3546/Library/Developer/Xcode/DerivedData/MasterDetail-fhgogwnbpzovbtaskgecptdnvgjs/Build/Intermediates/MasterDetail.build/Debug-iphonesimulator/MasterDetail.build/Objects-normal/i386/MasterDetail.LinkFileList -Xlinker -objc_abi_version -Xlinker 2 -fobjc-link-runtime -Xlinker -no_implicit_dylibs -mios-simulator-version-min=5.0 -framework UIKit -framework Foundation -framework CoreGraphics -o /Users/ilia3546/Library/Developer/Xcode/DerivedData/MasterDetail-fhgogwnbpzovbtaskgecptdnvgjs/Build/Products/Debug-iphonesimulator/MasterDetail.app/MasterDetail
duplicate symbol _main in:
/Users/ilia3546/Library/Developer/Xcode/DerivedData/MasterDetail-fhgogwnbpzovbtaskgecptdnvgjs/Build/Intermediates/MasterDetail.build/Debug-iphonesimulator/MasterDetail.build/Objects-normal/i386/main-E0BAF2CA88EDEE32.o
duplicate symbol _OBJC_IVAR_$_MasterDetailAppDelegate._window in:
/Users/ilia3546/Library/Developer/Xcode/DerivedData/MasterDetail-fhgogwnbpzovbtaskgecptdnvgjs/Build/Intermediates/MasterDetail.build/Debug-iphonesimulator/MasterDetail.build/Objects-normal/i386/MasterDetailAppDelegate-C2C06F734ECE2E36.o
duplicate symbol _OBJC_IVAR_$_MasterDetailAppDelegate._navigationController in:
/Users/ilia3546/Library/Developer/Xcode/DerivedData/MasterDetail-fhgogwnbpzovbtaskgecptdnvgjs/Build/Intermediates/MasterDetail.build/Debug-iphonesimulator/MasterDetail.build/Objects-normal/i386/MasterDetailAppDelegate-C2C06F734ECE2E36.o
duplicate symbol _OBJC_IVAR_$_MasterDetailAppDelegate._splitViewController in:
/Users/ilia3546/Library/Developer/Xcode/DerivedData/MasterDetail-fhgogwnbpzovbtaskgecptdnvgjs/Build/Intermediates/MasterDetail.build/Debug-iphonesimulator/MasterDetail.build/Objects-normal/i386/MasterDetailAppDelegate-C2C06F734ECE2E36.o
duplicate symbol _OBJC_CLASS_$_MasterDetailAppDelegate in:
/Users/ilia3546/Library/Developer/Xcode/DerivedData/MasterDetail-fhgogwnbpzovbtaskgecptdnvgjs/Build/Intermediates/MasterDetail.build/Debug-iphonesimulator/MasterDetail.build/Objects-normal/i386/MasterDetailAppDelegate-C2C06F734ECE2E36.o
duplicate symbol _OBJC_METACLASS_$_MasterDetailAppDelegate in:
/Users/ilia3546/Library/Developer/Xcode/DerivedData/MasterDetail-fhgogwnbpzovbtaskgecptdnvgjs/Build/Intermediates/MasterDetail.build/Debug-iphonesimulator/MasterDetail.build/Objects-normal/i386/MasterDetailAppDelegate-C2C06F734ECE2E36.o
duplicate symbol _OBJC_IVAR_$_MasterDetailDetailViewController._detailItem in:
/Users/ilia3546/Library/Developer/Xcode/DerivedData/MasterDetail-fhgogwnbpzovbtaskgecptdnvgjs/Build/Intermediates/MasterDetail.build/Debug-iphonesimulator/MasterDetail.build/Objects-normal/i386/MasterDetailDetailViewController-B3C32DC7B1BE4E38.o
duplicate symbol _OBJC_IVAR_$_MasterDetailDetailViewController._TitleOfDetail in:
/Users/ilia3546/Library/Developer/Xcode/DerivedData/MasterDetail-fhgogwnbpzovbtaskgecptdnvgjs/Build/Intermediates/MasterDetail.build/Debug-iphonesimulator/MasterDetail.build/Objects-normal/i386/MasterDetailDetailViewController-B3C32DC7B1BE4E38.o
duplicate symbol _OBJC_IVAR_$_MasterDetailDetailViewController._detailDescriptionLabel in:
/Users/ilia3546/Library/Developer/Xcode/DerivedData/MasterDetail-fhgogwnbpzovbtaskgecptdnvgjs/Build/Intermediates/MasterDetail.build/Debug-iphonesimulator/MasterDetail.build/Objects-normal/i386/MasterDetailDetailViewController-B3C32DC7B1BE4E38.o
duplicate symbol _OBJC_IVAR_$_MasterDetailDetailViewController._masterPopoverController in:
/Users/ilia3546/Library/Developer/Xcode/DerivedData/MasterDetail-fhgogwnbpzovbtaskgecptdnvgjs/Build/Intermediates/MasterDetail.build/Debug-iphonesimulator/MasterDetail.build/Objects-normal/i386/MasterDetailDetailViewController-B3C32DC7B1BE4E38.o
duplicate symbol _OBJC_IVAR_$_MasterDetailDetailViewController.WebView in:
/Users/ilia3546/Library/Developer/Xcode/DerivedData/MasterDetail-fhgogwnbpzovbtaskgecptdnvgjs/Build/Intermediates/MasterDetail.build/Debug-iphonesimulator/MasterDetail.build/Objects-normal/i386/MasterDetailDetailViewController-B3C32DC7B1BE4E38.o
duplicate symbol _OBJC_CLASS_$_MasterDetailDetailViewController in:
/Users/ilia3546/Library/Developer/Xcode/DerivedData/MasterDetail-fhgogwnbpzovbtaskgecptdnvgjs/Build/Intermediates/MasterDetail.build/Debug-iphonesimulator/MasterDetail.build/Objects-normal/i386/MasterDetailDetailViewController-B3C32DC7B1BE4E38.o
duplicate symbol _OBJC_METACLASS_$_MasterDetailDetailViewController in:
/Users/ilia3546/Library/Developer/Xcode/DerivedData/MasterDetail-fhgogwnbpzovbtaskgecptdnvgjs/Build/Intermediates/MasterDetail.build/Debug-iphonesimulator/MasterDetail.build/Objects-normal/i386/MasterDetailDetailViewController-B3C32DC7B1BE4E38.o
duplicate symbol _OBJC_IVAR_$_MasterDetailMasterViewController._detailViewController in:
/Users/ilia3546/Library/Developer/Xcode/DerivedData/MasterDetail-fhgogwnbpzovbtaskgecptdnvgjs/Build/Intermediates/MasterDetail.build/Debug-iphonesimulator/MasterDetail.build/Objects-normal/i386/MasterDetailMasterViewController-A4C5EC1C14AE6E3A.o
duplicate symbol _OBJC_IVAR_$_MasterDetailMasterViewController._Controller1 in:
/Users/ilia3546/Library/Developer/Xcode/DerivedData/MasterDetail-fhgogwnbpzovbtaskgecptdnvgjs/Build/Intermediates/MasterDetail.build/Debug-iphonesimulator/MasterDetail.build/Objects-normal/i386/MasterDetailMasterViewController-A4C5EC1C14AE6E3A.o
duplicate symbol _OBJC_IVAR_$_MasterDetailMasterViewController.listOfDecide in:
/Users/ilia3546/Library/Developer/Xcode/DerivedData/MasterDetail-fhgogwnbpzovbtaskgecptdnvgjs/Build/Intermediates/MasterDetail.build/Debug-iphonesimulator/MasterDetail.build/Objects-normal/i386/MasterDetailMasterViewController-A4C5EC1C14AE6E3A.o
duplicate symbol _OBJC_IVAR_$_MasterDetailMasterViewController.listOfDecideOpis in:
/Users/ilia3546/Library/Developer/Xcode/DerivedData/MasterDetail-fhgogwnbpzovbtaskgecptdnvgjs/Build/Intermediates/MasterDetail.build/Debug-iphonesimulator/MasterDetail.build/Objects-normal/i386/MasterDetailMasterViewController-A4C5EC1C14AE6E3A.o
duplicate symbol _OBJC_IVAR_$_MasterDetailMasterViewController.listOfGraph in:
/Users/ilia3546/Library/Developer/Xcode/DerivedData/MasterDetail-fhgogwnbpzovbtaskgecptdnvgjs/Build/Intermediates/MasterDetail.build/Debug-iphonesimulator/MasterDetail.build/Objects-normal/i386/MasterDetailMasterViewController-A4C5EC1C14AE6E3A.o
duplicate symbol _OBJC_IVAR_$_MasterDetailMasterViewController.listOfGraphOpis in:
/Users/ilia3546/Library/Developer/Xcode/DerivedData/MasterDetail-fhgogwnbpzovbtaskgecptdnvgjs/Build/Intermediates/MasterDetail.build/Debug-iphonesimulator/MasterDetail.build/Objects-normal/i386/MasterDetailMasterViewController-A4C5EC1C14AE6E3A.o
duplicate symbol _OBJC_IVAR_$_MasterDetailMasterViewController.listOfAbout in:
/Users/ilia3546/Library/Developer/Xcode/DerivedData/MasterDetail-fhgogwnbpzovbtaskgecptdnvgjs/Build/Intermediates/MasterDetail.build/Debug-iphonesimulator/MasterDetail.build/Objects-normal/i386/MasterDetailMasterViewController-A4C5EC1C14AE6E3A.o
duplicate symbol _OBJC_IVAR_$_MasterDetailMasterViewController.listOfAboutOpis in:
/Users/ilia3546/Library/Developer/Xcode/DerivedData/MasterDetail-fhgogwnbpzovbtaskgecptdnvgjs/Build/Intermediates/MasterDetail.build/Debug-iphonesimulator/MasterDetail.build/Objects-normal/i386/MasterDetailMasterViewController-A4C5EC1C14AE6E3A.o
duplicate symbol _OBJC_CLASS_$_MasterDetailMasterViewController in:
/Users/ilia3546/Library/Developer/Xcode/DerivedData/MasterDetail-fhgogwnbpzovbtaskgecptdnvgjs/Build/Intermediates/MasterDetail.build/Debug-iphonesimulator/MasterDetail.build/Objects-normal/i386/MasterDetailMasterViewController-A4C5EC1C14AE6E3A.o
duplicate symbol _OBJC_METACLASS_$_MasterDetailMasterViewController in:
/Users/ilia3546/Library/Developer/Xcode/DerivedData/MasterDetail-fhgogwnbpzovbtaskgecptdnvgjs/Build/Intermediates/MasterDetail.build/Debug-iphonesimulator/MasterDetail.build/Objects-normal/i386/MasterDetailMasterViewController-A4C5EC1C14AE6E3A.o
ld: 23 duplicate symbols for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
appdelegate.m -
#import "MasterDetailAppDelegate.h"
#import "MasterDetailMasterViewController.h"
#import "MasterDetailDetailViewController.h"
#implementation MasterDetailAppDelegate
#synthesize window = _window;
#synthesize navigationController = _navigationController;
#synthesize splitViewController = _splitViewController;
- (void)dealloc
{
[_window release];
[_navigationController release];
[_splitViewController release];
[super dealloc];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
MasterDetailMasterViewController *masterViewController = [[[MasterDetailMasterViewController alloc] initWithNibName:#"MasterDetailMasterViewController_iPhone" bundle:nil] autorelease];
self.navigationController = [[[UINavigationController alloc] initWithRootViewController:masterViewController] autorelease];
self.window.rootViewController = self.navigationController;
} else {
MasterDetailMasterViewController *masterViewController = [[[MasterDetailMasterViewController alloc] initWithNibName:#"MasterDetailMasterViewController_iPad" bundle:nil] autorelease];
UINavigationController *masterNavigationController = [[[UINavigationController alloc] initWithRootViewController:masterViewController] autorelease];
MasterDetailDetailViewController *detailViewController = [[[MasterDetailDetailViewController alloc] initWithNibName:#"MasterDetailDetailViewController_iPad" bundle:nil] autorelease];
UINavigationController *detailNavigationController = [[[UINavigationController alloc] initWithRootViewController:detailViewController] autorelease];
self.splitViewController = [[[UISplitViewController alloc] init] autorelease];
self.splitViewController.delegate = detailViewController;
self.splitViewController.viewControllers = [NSArray arrayWithObjects:masterNavigationController, detailNavigationController, nil];
self.window.rootViewController = self.splitViewController;
}
[self.window makeKeyAndVisible];
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application
{
/*
Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
*/
}
- (void)applicationDidEnterBackground:(UIApplication *)application
{
/*
Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
*/
}
- (void)applicationWillEnterForeground:(UIApplication *)application
{
/*
Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
*/
}
- (void)applicationDidBecomeActive:(UIApplication *)application
{
/*
Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
*/
}
- (void)applicationWillTerminate:(UIApplication *)application
{
/*
Called when the application is about to terminate.
Save data if appropriate.
See also applicationDidEnterBackground:.
*/
}
#end
main.m -
//
// main.m
// MasterDetail
//
// Created by Wei-Meng Lee on 3/9/11.
// Copyright (c) 2011 __MyCompanyName__. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "MasterDetailAppDelegate.h"
int main(int argc, char *argv[])
{
#autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([MasterDetailAppDelegate class]));
}
}
I checked importing the .m file instead of the .h, but all correctly.
Check your import files, it may that you're importing a .m file.
#import "TimeModel.m"
In your build phases, check to see that you aren't compiling the same file more than once. i.e. If you search for main.m it should only return one result.
If that's not the problem, can you add the code from your main.m to the question?
Although the following is not the cause in the OP's case, it was mine, so I'll share it here for anyone facing the same error:
If you are getting a linker error on all global variables, you might need to add extern to their declarations in your header files.
Whether the lack of extern will generate this issue is dependent on build settings, more specifically on "No Common Blocks" under "Apple LLVM - Code Generation" (GCC_NO_COMMON_BLOCKS, -fno-common). If set to yes, which is the default in newer versions of Xcode, you'll get a linker error without extern.
Why extern?
The extern keywords makes it a declaration only (i.e. not also a definition), which since it's a header file is what you want. Some compilers allow it without extern and still 'do the right thing', but omitting extern is discouraged. Which is why newer versions of Xcode by default enable the warning.
Here is a situation in Xcode 7.0 with duplicate symbols error, in case anyone else comes across this scenario
.h file
NSUserDefaults *defaults; // <----placing this above the #interface caused the issue
#interface someViewController
//...
Change to
.h file
#interface someViewController
{
NSUserDefaults *defaults;
}
//...
This could happen also when you have the same #interface in different files with different implementations. For example you have a Player class, in the Player.h/m files and you have a Match class (Match.h/m), and a match is between two player, but not the aforementioned Player.
Player.h
#interface Player : NSObject
#property (nonatomic) NSUInteger _id;
#property (nonatomic, strong) NSString* firstName;
#property (nonatomic, strong) NSString* lastName;
#property (nonatomic, strong) NSString* username;
#end
Match.h
#class Player
#interface Match : NSObject
#property (nonatomic, strong) Player* player1;
#property (nonatomic, strong) Player* player2;
#property (nonatomic) NSUInteger matchId;
#end
#interface Player : NSObject
#property (nonatomic, strong) NSString* nickName;
#property (nonatomic, strong) NSString* point;
#property (nonatomic, strong) NSNumber* lastMove;
#end
In this case the the compiler see two different Player class implementation. You need to refactor the Player class in the Match.h file to MatchPlayer.
I ran into an issue where typedef was not added to an enum and the duplicate symbol error appeared between 2 files.
enum <name> {
...
} <name>;
By adding typedef before enum fixed the duplicate symbol.
In my case the problem was that .m file was included twice.
PROBLEM:
REASON:
SOLUTION: Leave only one file reference.
If this helps others, that was my case :
I wanted to declare 2 small classes in 1 header and implementation file.
Class 2 is using Class 1
When I got the error this was the situation:
header file - interface+implementation of class 1 , interface of class 2
Implementation file - implementation of class 2
After I moved the implementation of class 1 from header file to implementation file, there was no error and problem solved :
header file - interface of class 1 , interface of class 2
Implementation file - implementation of class 1, implementation of class 2
In my case, I had identical entity name and NSManagedObject names and failed to set the entity Class Codegen to "Manual/None" in the Data Model Inspector.
Related
I am getting error:use of undeclared identifier
here is the code for view controller where I am accessing the object of model class mapMembersData
for (NSMutableDictionary *getMemberElements in arData)
{
mapMembersData *notModelObject = [mapMembersData sharedInstance];//showing error
[notModelObject assignMemberData:getMemberElements];
[memberArray addObject:notModelObject];
}
Here is the code of model class:
#import <CoreLocation/CoreLocation.h>
#import <Google-Maps-iOS-Utils/GMUMarkerClustering.h>
#interface mapMembersData : NSObject<GMUClusterItem>
#property(nonatomic,retain) NSString *chatToken;
#property(nonatomic,retain) NSString *address;
+ (mapMembersData *)sharedInstance;
- (mapMembersData *)assignMemberData:
#end
#import "mapMembersData.h"
#import "Constants.h"
#implementation mapMembersData
#synthesize chatToken,
address,
static mapMembersData *instance;
+(mapMembersData *)sharedInstance{
#synchronized(self)
{
instance = [[super alloc] init];
}
return instance;
}
- (mapMembersData *)assignMemberData:(NSMutableDictionary*)getMemberElements
{
chatToken = [objdelegate checkIfStringIsEmpty:[getMemberElements
objectForKey:#"chatToken"]];
address = [objdelegate checkIfStringIsEmpty:[getMemberElements
objectForKey:#"address"]];
return self;
}
#end
What am I doing wrong?
In your storyboard there must be a controller, in which you had set a class with storyboard id, and you removed that class from that storyboard but the storyboard id is still addressing it, like below image:
So you have to remove that Storyboard ID and uncheck that "Use Story Board ID".
That's all.
After scratching my head for a day. I manage to get ride off the bizarre errors.
Finding starts from below:
1.mapMembersData-class were residing in two different folders of the workspace (In XYZ-folder and one at outside the folder). mapMembersData- the class was referenced by project i.e inside XYZ and other was just placed.
the controller from where I was accessing the mapMembersData, was at outside XYZ-folder, thus creating ambiguity.
I deleted unused referenced classed and confirm controller should access correctly.
This is ridiculous, im trying to create a sound bool to turn of in app sounds. I keep getting
Undefined symbols for architecture i386:
"_kPlaySoundPrefsKey", referenced from:
-[AppDelegate application:didFinishLaunchingWithOptions:] in AppDelegate.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I have checked that all my files are linked in build phases, I have deleted the appdelegate .m where im getting the error before I even get to call the bool in any of my view controllers, and re imported it in build phases. Checked I have relevant framweworks in place. I have even checked a previous app I made with same code and the code it appears to be exactly the same with no error (built with previous version of xcode). Taking it right back to basics I get the error as soon as I add the following code to my App Delegate,
.h
#import <UIKit/UIKit.h>
extern NSString *kPlaySoundPrefsKey;
#interface AppDelegate : UIResponder <UIApplicationDelegate>
#property (strong, nonatomic) UIWindow *window;
#end
.m
#import "AppDelegate.h"
#import <AudioToolbox/AudioToolbox.h>
#implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions: (NSDictionary *)launchOptions
{
NSDictionary *defaultDict = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES]
forKey:kPlaySoundPrefsKey];
return YES;
}
If I change extern NSString *kPlaySoundPrefsKey; to NSString *kPlaySoundPrefsKey; it builds then crashes...Im out of ideas now
When you declaring something as extern you are telling the compiler the type AND that you will define it somewhere else. In your case you never define your variable.
So in your .h you would have:
extern NSString* kPlaySoundPrefsKey;
But in some .m you must also have
NSString* kPlaySoundPrefsKey = #"play_sounds"; // or some value
Since in your case these are constants you can also specify:
extern NSString* const kPlaySoundPrefsKey;
and
NSString* const kPlaySoundPrefsKey = #"play_sounds";
The addition of the const qualifier will cause a compiler error if someone ever writes something like
kPlaySoundPrefsKey = #"some_other_value";
I am also got the same error even if I am properly declared and define the extern const string ,
The problem is, my constant file not in the compile source list .
Make sure that your .m file appears in the "Compile Sources" Build Phase for your build target. Sometimes, adding files to a project in Xcode doesn't add all implementation files to the appropriate targets.
Hope this will helpful for some people.
Refe: linker-error-undefined-symbols-symbols-not-found
First, ensure it is defined:
// AppDelegate.h
extern NSString* const kPlaySoundPrefsKey; // << declaration
// AppDelegate.m
NSString * const kPlaySoundPrefsKey = #"kPlaySoundPrefsKey"; // << definition
see also:
"extern const" vs "extern" only
3 questions about extern used in an Objective-C project
Linker error using extern "C" in Objective-C code
Thanks for your help guys
I added
NSString *kPlaySoundPrefsKey = #"playSoundKey";
[[NSUserDefaults standardUserDefaults] registerDefaults:defaultDict];
to app delegate. That fixed it
I'm fairly new to Objective-C and I'm running into a problem.
I need to pass some information from one viewcontroller to another. I've tried a number of methods and either get build error or don't make enough sense.
Here is what I have so far.
In the second view controllers h file:
#property (nonatomic) NSString *OwnerID;
The data should go into this property.
In the first view controllers m file:
MoreByUserViewController *moreimg =[[MoreByUserViewController alloc] init];
moreimg.OwnerID = ImageOener;
I think this isn't correct but don't know what else to write.
The clang error I get:
duplicate symbol _m_PageCounter in:
/Users/ianspence/Library/Developer/Xcode/DerivedData/Pickr-dohtanjxfozprjbuwlphjbhvxttm/Build/Intermediates/Pickr.build/Debug-iphonesimulator/Pickr.build/Objects-normal/i386/PKRViewController.o
/Users/ianspence/Library/Developer/Xcode/DerivedData/Pickr-dohtanjxfozprjbuwlphjbhvxttm/Build/Intermediates/Pickr.build/Debug-iphonesimulator/Pickr.build/Objects-normal/i386/MoreByUserViewController.o
ld: 1 duplicate symbol for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Is it a circular reference? check out your header files.
Your problem is something else, now you are getting error for _m_PageCounter. I think twice you put m_PageCounter or used same variable in two different headers..
in .h file just declare #class MoreByUserViewController. and add header file of MoreByUserViewController in .m fie.
#interface MoreByUserViewController : UIViewController
{
NSString *mOwnerID;
}
#property(nonatomic, retain) NSString *OwnerID;
-(id)initWithID:(NSString*)inId;
#end
#implementation MoreByUserViewController
#synthesize OwnerID = mOwnerID;
-(id)initWithID:(NSString*)inId
{
if(self = [super init])
{
self.OwnerID = inId;
}
return self;
}
#end
//Somewhere else in code
MoreByUserViewController *moreimg =[[MoreByUserViewController alloc] initWithID:#"AnyIdOnUrWish"];
duplicate symbol _m_PageCounter means you have a constant or variable or function named m_PageCounter defined in two places. Specifically, in PKRViewController.m and MoreByUserViewController.m.
Your options:
Delete one of them.
Rename one of them.
Declare one of them static so they won't be visible outside of that source file.
I am very new to development in Objective C but have a lot of experience in object orientated development in c# ASP. I've been trying to make a simple iPhone app where a PickerView control is accessing a data source.
In my header file (InstaTwitViewController.h) I have declared the following:
#interface InstaTwitViewController : UIViewController
<UIPickerViewDataSource, UIPickerViewDelegate> {
NSArray* activities;
NSArray* feelings;
}
I now try to inititialise my arrays in the viewDidLoad functions in my InstaTwitViewController.m file:
activities = [[NSArray alloc] initWithObjects:#"sleeping", #"eating", #"thinking", nil];
feelings = [[NSArray alloc] initWithObjects:#"psyched", #"sad", #"happy", nil];
but when I run the code on the simulator I get a Thread 1: Program recieved signal "ESC_BAD_ACCESS" error on the first line of code (where I allocate data to the activities array).
I put a break point on the line and it recognises it as an NSArray called activities but says "Invalid Summary" at the end.
Does anyone know why I am getting this error? I have looked at many threads about the ESC_BAD_ACCESS error but none have seemed to have helped me.
.h
#interface InstaTwitViewController : UIViewController <UIPickerViewDataSource, UIPickerViewDelegate> {
NSArray* activities;
NSArray* feelings;
}
#property (nonatomic, retain) NSArray* activities;
#property (nonatomic, retain) NSArray* feelings;
#end
.m
#import "your.h"
#implementation InstaTwitViewController
#synthesize activities, feelings;
- (void)viewDidLoad {
[super viewDidLoad];
[self.activities addObject ~ /* Do your code here */];
}
#end
Becareful you should stay on self.~ if you don't want to lose your value.
By the way, I am Korean~ ^^;
I am just learning how to use ScriptingBridges. I made a method that slowly fades the volume on iTunes, and would like to make it a category so I can do the following:
iTunesApplication* iTunes = [SBApplication applicationWithBundleIdentifier:#"com.apple.iTunes"];
[iTunes lowerVolume:50 speed:1];
I made another category for NSSpeechSynthesizer that works, but I can't get this one to. I keep getting the following build error:
"_OBJC_CLASS_$_iTunesApplication", referenced from:
l_OBJC_$_CATEGORY_iTunesApplication_$_iTunesApplicationAdditions in iTunesApplication.o
objc-class-ref-to-iTunesApplication in iTunesApplication.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
Is there something special I can do to make it work since I can't include the symbols?
Thanks,
Ryan Pendleton
UPDATE:
I only found one solution, which is below. It involves MethodSwizzling, so I'm open to better answers, but for now it's all I have.
The solution I found was to use the Objective-C runtime API. I'm sure there's a better way to organize this, but here's how I did it:
Here are my .h and .m files for creating the category. Notice how lowerVolume is not an actual method, but a C function with the arguments id self, and SEL _CMD. You'll also notice a setupCategories function. We'll call that later.
// iTunes+Volume.h
#import <objc/runtime.h>
#import "iTunes.h"
void lowerVolume(id self, SEL _cmd, int dest, float speed);
void setupCategories();
#interface iTunesApplication (Volume)
- (void)lowerVolume:(int)dest speed:(float)speed;
#end
// iTunes+Volume.m
#import "iTunes+Volume.h"
void lowerVolume(id self, SEL _cmd, int dest, float speed)
{
NSLog(#"Lower Volume: %i, %f", dest, speed);
}
void setupCategories()
{
id object = [[SBApplication alloc] initWithBundleIdentifier:#"com.apple.iTunes"];
Class class = [object class];
[object release];
class_addMethod(class, #selector(lowerVolume:speed:), (IMP)lowerVolume, "#:if");
}
Now that I've made the functions, I need to actually add them to the scripting bridge class using the Objective-C runtime API. I'll do this in main.m to make sure that the methods are ready to be used when the run loop starts.
// main.m
#import <Cocoa/Cocoa.h>
#import "iTunes+Volume.h"
int main(int argc, char *argv[])
{
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
setupCategories();
return NSApplicationMain(argc, (const char **) argv);
[pool drain];
}
Now, I can use my method wherever I want as long as I include the header files:
- (void)mute
{
iTunesApplication* iTunes = [[SBApplication alloc] initWithBundleIdentifier:#"com.apple.iTunes"];
[iTunes lowerVolume:0 speed:1];
[iTunes release];
}
If any of this doesn't make sense, just tell me and I'll try to explain it better.
I think you need to include -framework ScriptingBridge to your gcc arguments. That got it to compile for me!
As noted above, you can't easily do a category on iTunesApplication because it doesn't exist at compile time, and also because the runtime class name is ITunesApplication (capital "I").
The best solution I've found is to do your category on the class that DOES exist, SBApplication. Here's the code I tested that works and does what the original example was trying to do:
// SBApplication+Extensions.h
#import ScriptingBridge;
#interface SBApplication (Extensions)
- (void)lowerVolume:(int)dest speed:(float)speed;
#end
// SBApplication+Extensions.m
#import "iTunes.h"
#import "SBApplication+Extensions.h"
#implementation SBApplication (Extensions)
- (void)lowerVolume:(int)dest speed:(float)speed
{
NSLog(#"Lower Volume: %i, %f", dest, speed);
}
#end
// Caller, say in AppDelegate
#import "SBApplication+Extensions.h"
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
iTunesApplication *iTunesApp =
[SBApplication applicationWithBundleIdentifier:#"com.apple.iTunes"];
[iTunesApp lowerVolume:4 speed:3.3f];
}