Reputation: 19969
I am trying to build a category for a project (my first time). If I implement the category in the model (LTUser), it works fine but, if I put it into a different file called LTUser+Additions(.h / .m), it gives me "linker command failed with exit code 1 (use -v to see invocation)" error with "6 duplicate symobols for architecture i386". I'm not even sure where I would add -v on invocation. I have included a screenshot of the error. What am I doing wrong with my category?
LTUser+Additions.h
#import "LTUser.h"
@interface LTUser (Additions)
-(void)saySomethingMore;
+(void)tellMe;
@end
LTUser+Additions.m
#import "LTUser+Additions.h"
@implementation LTUser (Additions)
-(void)saySomethingMore{
NSLog(@"I want to say something more to you from within category");
}
+(void)tellMe
{
NSLog(@"I want you to tell me from the category");
}
@end
edit #1 so just adding an empty category via: File -> New -> File -> 'select Objective C Category' -next-> Set name to Add and Category on LTUser
It makes the .h / .m files but if I compile this, it gives me the same error. This is making me think that adding / deleting category files has mucked up the project but still not sure.
Upvotes: 2
Views: 95
Reputation: 539965
That strongly looks as if you #import
a .m-file instead of the .h-file somewhere.
The same error would also occur if you put the implementation into the .h file (which you should never do), and import the .h file from more than one place.
Upvotes: 2
Reputation: 19969
So this app was originally to just mock something up and I did a shortcut that I've done several times before but not had an issue. Rather than a .h / .m file, I put both the header and the implementation in the .h file. This worked ok when just rendering a simple object but when I added a category, it cause the above blow-up. It should probably be mentioned in the docs that, when adding a category, it MUST exist with the .h / .m file structure.
Upvotes: 0