我经历过已在论坛上提出的问题。获得如下错误
ld: 8 duplicate symbols for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
下面有更多错误说明
ld: warning: directory not found for option '-L/Users/Documents/Sprint1/iPhone/MyApplication/MyApplication/lib/lib'
ld: warning: directory not found for option '-Lrestkit'
ld: warning: ignoring file /Users/Documents/Sprint1/iPhone/MyApplication/MyApplication/lib/lib restkit/libRestKit.a, missing required architecture i386 in file /Users/Documents/Sprint1/iPhone/MyApplication/MyApplication/lib/lib restkit/libRestKit.a (2 slices)
duplicate symbol _OBJC_IVAR_$_Reachability.reachabilityRef in:
/Users/Library/Developer/Xcode/DerivedData/MyApplication-bchgbqjzuwjzbcbnhwyihhatsoyw/Build/Intermediates/MyApplication.build/Debug-iphonesimulator/MyApplication.build/Objects-normal/i386/Reachability.o
/Users/Library/Developer/Xcode/DerivedData/MyApplication-bchgbqjzuwjzbcbnhwyihhatsoyw/Build/Products/Debug-iphonesimulator/libPOSNirvanaUtils.a(Reachability.o)
duplicate symbol _kReachabilityChangedNotification in:
/Users/Library/Developer/Xcode/DerivedData/MyApplication-bchgbqjzuwjzbcbnhwyihhatsoyw/Build/Intermediates/MyApplication.build/Debug-iphonesimulator/MyApplication.build/Objects-normal/i386/Reachability.o
/Users/Library/Developer/Xcode/DerivedData/MyApplication-bchgbqjzuwjzbcbnhwyihhatsoyw/Build/Products/Debug-iphonesimulator/libPOSNirvanaUtils.a(Reachability.o)
duplicate symbol _kInternetConnection in:
/Users/Library/Developer/Xcode/DerivedData/MyApplication-bchgbqjzuwjzbcbnhwyihhatsoyw/Build/Intermediates/MyApplication.build/Debug-iphonesimulator/MyApplication.build/Objects-normal/i386/Reachability.o
/Users/Library/Developer/Xcode/DerivedData/MyApplication-bchgbqjzuwjzbcbnhwyihhatsoyw/Build/Products/Debug-iphonesimulator/libPOSNirvanaUtils.a(Reachability.o)
duplicate symbol _kLocalWiFiConnection in:
/Users/Library/Developer/Xcode/DerivedData/MyApplication-bchgbqjzuwjzbcbnhwyihhatsoyw/Build/Intermediates/MyApplication.build/Debug-iphonesimulator/MyApplication.build/Objects-normal/i386/Reachability.o
/Users/Library/Developer/Xcode/DerivedData/MyApplication-bchgbqjzuwjzbcbnhwyihhatsoyw/Build/Products/Debug-iphonesimulator/libPOSNirvanaUtils.a(Reachability.o)
duplicate symbol _OBJC_IVAR_$_Reachability.key_ in:
/Users/Library/Developer/Xcode/DerivedData/MyApplication-bchgbqjzuwjzbcbnhwyihhatsoyw/Build/Intermediates/MyApplication.build/Debug-iphonesimulator/MyApplication.build/Objects-normal/i386/Reachability.o
/Users/Library/Developer/Xcode/DerivedData/MyApplication-bchgbqjzuwjzbcbnhwyihhatsoyw/Build/Products/Debug-iphonesimulator/libPOSNirvanaUtils.a(Reachability.o)
duplicate symbol _OBJC_CLASS_$_Reachability in:
/Users/Library/Developer/Xcode/DerivedData/MyApplication-bchgbqjzuwjzbcbnhwyihhatsoyw/Build/Intermediates/MyApplication.build/Debug-iphonesimulator/MyApplication.build/Objects-normal/i386/Reachability.o
/Users/Library/Developer/Xcode/DerivedData/MyApplication-bchgbqjzuwjzbcbnhwyihhatsoyw/Build/Products/Debug-iphonesimulator/libPOSNirvanaUtils.a(Reachability.o)
duplicate symbol _OBJC_METACLASS_$_Reachability in:
/Users/Library/Developer/Xcode/DerivedData/MyApplication-bchgbqjzuwjzbcbnhwyihhatsoyw/Build/Intermediates/MyApplication.build/Debug-iphonesimulator/MyApplication.build/Objects-normal/i386/Reachability.o
/Users/Library/Developer/Xcode/DerivedData/MyApplication-bchgbqjzuwjzbcbnhwyihhatsoyw/Build/Products/Debug-iphonesimulator/libPOSNirvanaUtils.a(Reachability.o)
duplicate symbol _kConnectionDown in:
/Users/Library/Developer/Xcode/DerivedData/MyApplication-bchgbqjzuwjzbcbnhwyihhatsoyw/Build/Intermediates/MyApplication.build/Debug-iphonesimulator/MyApplication.build/Objects-normal/i386/Reachability.o
/Users/Library/Developer/Xcode/DerivedData/MyApplication-bchgbqjzuwjzbcbnhwyihhatsoyw/Build/Products/Debug-iphonesimulator/libPOSNirvanaUtils.a(Reachability.o)
ld: 8 duplicate symbols for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
我有像
这样的项目结构情况 1)静态库A依赖于静态库B.项目A需要可达性检查。 2)在应用程序项目中添加静态库A. 3)编译时,遇到链接器错误
请帮助解决此问题。
答案 0 :(得分:1)
如果此解决方案无效,请检查此..
此错误经常发生的另一个原因是意外导入.m文件而不是.h。
答案 1 :(得分:0)
步骤:
1.在目标设置中检查构建阶段。
2.检查文件是否存在两次或一次。
3.如果文件存在两次删除一个。如果没有删除底部最新的文件。
4.再次建造。
答案 2 :(得分:0)
Reachability
& libPOSNirvanaUtils.a
中有libPOSNirvanaUtils.a
个班级您的应用程序,并且您在应用程序中使用Reachability
。所以现在你的应用程序有2个libPOSNirvanaUtils.a
类的引用。
如果您正在构建Reachability
,那么您可以通过两种方式解决此问题:
libPOSNirvanaUtils.a
Reachability
班级成员资格
Reachability
类,从应用程序中删除{{1}}类引用,并使用libPOSNirvanaUtils中的相同类引用。答案 3 :(得分:0)
使用prepareforsegue委托时我遇到了同样的问题。事实证明,我不小心导入了.m文件而不是.h文件。这将解决它。在疯狂添加和删除框架之前,请查看#import语句。
答案 4 :(得分:0)
在我的情况下,我得到了这个错误,因为在实现部分的几个文件中声明了相同的命名变量。
@implementation A
int a;
...
@implementation B
int a;
...
给了我"重复符号_a ..."