问题
I am having an issue understanding a linker command error. I am receiving the following:
duplicate symbol _OBJC_IVAR_$_XYZAddToDoItemViewController._toDoItem in:
/Users/*/Library/Developer/Xcode/DerivedData/ToDoToday-fjyijxlbvauebmeuhtgdvdrjtfez/Build/Intermediates/ToDoToday.build/Debug-iphonesimulator/ToDoToday.build/Objects-normal/i386/XYZToDoListViewController.o
/Users/*/Library/Developer/Xcode/DerivedData/ToDoToday-fjyijxlbvauebmeuhtgdvdrjtfez/Build/Intermediates/ToDoToday.build/Debug-iphonesimulator/ToDoToday.build/Objects-normal/i386/XYZAddToDoItemViewController.o
duplicate symbol _OBJC_CLASS_$_XYZAddToDoItemViewController in:
/Users/*/Library/Developer/Xcode/DerivedData/ToDoToday-fjyijxlbvauebmeuhtgdvdrjtfez/Build/Intermediates/ToDoToday.build/Debug-iphonesimulator/ToDoToday.build/Objects-normal/i386/XYZToDoListViewController.o
/Users/*/Library/Developer/Xcode/DerivedData/ToDoToday-fjyijxlbvauebmeuhtgdvdrjtfez/Build/Intermediates/ToDoToday.build/Debug-iphonesimulator/ToDoToday.build/Objects-normal/i386/XYZAddToDoItemViewController.o
duplicate symbol _OBJC_METACLASS_$_XYZAddToDoItemViewController in:
/Users/*/Library/Developer/Xcode/DerivedData/ToDoToday-fjyijxlbvauebmeuhtgdvdrjtfez/Build/Intermediates/ToDoToday.build/Debug-iphonesimulator/ToDoToday.build/Objects-normal/i386/XYZToDoListViewController.o
/Users/*/Library/Developer/Xcode/DerivedData/ToDoToday-fjyijxlbvauebmeuhtgdvdrjtfez/Build/Intermediates/ToDoToday.build/Debug-iphonesimulator/ToDoToday.build/Objects-normal/i386/XYZAddToDoItemViewController.o
ld: 3 duplicate symbols for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I'm not sure which symbols Xcode is referring to exactly. Below are the top of the implementation files.
XYZToDoListViewController.m:
#import "XYZAddToDoItemViewController.h"
@interface XYZAddToDoItemViewController ()
@property NSMutableArray *toDoItems;
@end
@implementation XYZAddToDoItemViewController
XYZAddToDoItemViewController.m:
#import "XYZAddToDoItemViewController.h"
@interface XYZAddToDoItemViewController ()
@property (weak, nonatomic) IBOutlet UITextField *textField;
@property (weak, nonatomic) IBOutlet UIBarButtonItem *doneButton;
@end
@implementation XYZAddToDoItemViewController
Any help would be much appreciated, thank you.
回答1:
In your XYZToDoListViewController.m
change:
@interface XYZAddToDoItemViewController ()
to:
@interface XYZToDoListViewController ()
and:
@implementation XYZAddToDoItemViewController
to:
@implementation XYZToDoListViewController
and:
#import "XYZAddToDoItemViewController.h"
to:
#import "XYZToDoListViewController.h"
Basically you have the wrong class name in the XYZToDoListViewController.m
file.
Make you don't have the same mistake in the XYZToDoListViewController.h
file.
回答2:
I encounter this error when I import A.m in B.m
Make sure you only import .h files
来源:https://stackoverflow.com/questions/19941747/ios-3-duplicate-symbols-for-architecture-i386