我遇到了解链接器命令错误的问题。我收到以下信息:
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)
我不确定Xcode指的是哪些符号。以下是实现文件的顶部。
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
非常感谢任何帮助,谢谢。
答案 0 :(得分:2)
在XYZToDoListViewController.m
更改:
@interface XYZAddToDoItemViewController ()
为:
@interface XYZToDoListViewController ()
和
@implementation XYZAddToDoItemViewController
为:
@implementation XYZToDoListViewController
和
#import "XYZAddToDoItemViewController.h"
为:
#import "XYZToDoListViewController.h"
基本上,XYZToDoListViewController.m
文件中的类名错误。
让你在XYZToDoListViewController.h
文件中没有同样的错误。
答案 1 :(得分:0)
我在B.m
中导入A.m时遇到此错误确保只导入.h文件