Objective-C错误:链接器命令失败,退出代码为1(使用-v查看调用)

时间:2016-04-18 06:45:57

标签: objective-c xcode linker

(如果您有任何想法,无论它是什么,请发回答,我会给你+1,即使它没有解决我的情况:))

刚收到此错误。

我用Google搜索了它,到目前为止找不到任何解决方案。

linker command failed with exit code 1 (use -v to see invocation) duplicate symbols for architecture x86_64

clang: error: linker command failed with exit code 1 (use -v to see invocation) duplicate symbol _sprites for _game

linker command failed with exit code 1 (use -v to see invocation) and Undefined symbols for architecture

Ld /Users/TLL/Library/Developer/Xcode/DerivedData/AFDateHelperExtObjective-C-drnbulhrpdtwsbctmtvxzbnfjavn/Build/Products/Debug-iphonesimulator/AFDateHelperExtObjective-C.app/AFDateHelperExtObjective-C normal x86_64
    cd "/Users/TLL/Desktop/iOS Learn/Objective-C Mark Price Udemy/Ex 6 AFDateHelper /AFDateHelperExtObjective-C"
    export IPHONEOS_DEPLOYMENT_TARGET=9.2
    export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk -L/Users/TLL/Library/Developer/Xcode/DerivedData/AFDateHelperExtObjective-C-drnbulhrpdtwsbctmtvxzbnfjavn/Build/Products/Debug-iphonesimulator -F/Users/TLL/Library/Developer/Xcode/DerivedData/AFDateHelperExtObjective-C-drnbulhrpdtwsbctmtvxzbnfjavn/Build/Products/Debug-iphonesimulator -filelist /Users/TLL/Library/Developer/Xcode/DerivedData/AFDateHelperExtObjective-C-drnbulhrpdtwsbctmtvxzbnfjavn/Build/Intermediates/AFDateHelperExtObjective-C.build/Debug-iphonesimulator/AFDateHelperExtObjective-C.build/Objects-normal/x86_64/AFDateHelperExtObjective-C.LinkFileList -Xlinker -rpath -Xlinker @executable_path/Frameworks -mios-simulator-version-min=9.2 -Xlinker -objc_abi_version -Xlinker 2 -fobjc-arc -fobjc-link-runtime -Xlinker -dependency_info -Xlinker /Users/TLL/Library/Developer/Xcode/DerivedData/AFDateHelperExtObjective-C-drnbulhrpdtwsbctmtvxzbnfjavn/Build/Intermediates/AFDateHelperExtObjective-C.build/Debug-iphonesimulator/AFDateHelperExtObjective-C.build/Objects-normal/x86_64/AFDateHelperExtObjective-C_dependency_info.dat -o /Users/TLL/Library/Developer/Xcode/DerivedData/AFDateHelperExtObjective-C-drnbulhrpdtwsbctmtvxzbnfjavn/Build/Products/Debug-iphonesimulator/AFDateHelperExtObjective-C.app/AFDateHelperExtObjective-C

duplicate symbol _ISOFormatYear in:
    /Users/TLL/Library/Developer/Xcode/DerivedData/AFDateHelperExtObjective-C-drnbulhrpdtwsbctmtvxzbnfjavn/Build/Intermediates/AFDateHelperExtObjective-C.build/Debug-iphonesimulator/AFDateHelperExtObjective-C.build/Objects-normal/x86_64/ViewController.o
    /Users/TLL/Library/Developer/Xcode/DerivedData/AFDateHelperExtObjective-C-drnbulhrpdtwsbctmtvxzbnfjavn/Build/Intermediates/AFDateHelperExtObjective-C.build/Debug-iphonesimulator/AFDateHelperExtObjective-C.build/Objects-normal/x86_64/NSDate+AFDateHelperObjC.o
duplicate symbol _ISOFormatYearMonth in:
    /Users/TLL/Library/Developer/Xcode/DerivedData/AFDateHelperExtObjective-C-drnbulhrpdtwsbctmtvxzbnfjavn/Build/Intermediates/AFDateHelperExtObjective-C.build/Debug-iphonesimulator/AFDateHelperExtObjective-C.build/Objects-normal/x86_64/ViewController.o
    /Users/TLL/Library/Developer/Xcode/DerivedData/AFDateHelperExtObjective-C-drnbulhrpdtwsbctmtvxzbnfjavn/Build/Intermediates/AFDateHelperExtObjective-C.build/Debug-iphonesimulator/AFDateHelperExtObjective-C.build/Objects-normal/x86_64/NSDate+AFDateHelperObjC.o
duplicate symbol _ISOFormatDate in:
    /Users/TLL/Library/Developer/Xcode/DerivedData/AFDateHelperExtObjective-C-drnbulhrpdtwsbctmtvxzbnfjavn/Build/Intermediates/AFDateHelperExtObjective-C.build/Debug-iphonesimulator/AFDateHelperExtObjective-C.build/Objects-normal/x86_64/ViewController.o
    /Users/TLL/Library/Developer/Xcode/DerivedData/AFDateHelperExtObjective-C-drnbulhrpdtwsbctmtvxzbnfjavn/Build/Intermediates/AFDateHelperExtObjective-C.build/Debug-iphonesimulator/AFDateHelperExtObjective-C.build/Objects-normal/x86_64/NSDate+AFDateHelperObjC.o
duplicate symbol _DotNetDateFormatType in:
    /Users/TLL/Library/Developer/Xcode/DerivedData/AFDateHelperExtObjective-C-drnbulhrpdtwsbctmtvxzbnfjavn/Build/Intermediates/AFDateHelperExtObjective-C.build/Debug-iphonesimulator/AFDateHelperExtObjective-C.build/Objects-normal/x86_64/ViewController.o
    /Users/TLL/Library/Developer/Xcode/DerivedData/AFDateHelperExtObjective-C-drnbulhrpdtwsbctmtvxzbnfjavn/Build/Intermediates/AFDateHelperExtObjective-C.build/Debug-iphonesimulator/AFDateHelperExtObjective-C.build/Objects-normal/x86_64/NSDate+AFDateHelperObjC.o
duplicate symbol _CustomDateFormatType in:
    /Users/TLL/Library/Developer/Xcode/DerivedData/AFDateHelperExtObjective-C-drnbulhrpdtwsbctmtvxzbnfjavn/Build/Intermediates/AFDateHelperExtObjective-C.build/Debug-iphonesimulator/AFDateHelperExtObjective-C.build/Objects-normal/x86_64/ViewController.o
    /Users/TLL/Library/Developer/Xcode/DerivedData/AFDateHelperExtObjective-C-drnbulhrpdtwsbctmtvxzbnfjavn/Build/Intermediates/AFDateHelperExtObjective-C.build/Debug-iphonesimulator/AFDateHelperExtObjective-C.build/Objects-normal/x86_64/NSDate+AFDateHelperObjC.o
duplicate symbol _AltRSSDateFormatType in:
    /Users/TLL/Library/Developer/Xcode/DerivedData/AFDateHelperExtObjective-C-drnbulhrpdtwsbctmtvxzbnfjavn/Build/Intermediates/AFDateHelperExtObjective-C.build/Debug-iphonesimulator/AFDateHelperExtObjective-C.build/Objects-normal/x86_64/ViewController.o
    /Users/TLL/Library/Developer/Xcode/DerivedData/AFDateHelperExtObjective-C-drnbulhrpdtwsbctmtvxzbnfjavn/Build/Intermediates/AFDateHelperExtObjective-C.build/Debug-iphonesimulator/AFDateHelperExtObjective-C.build/Objects-normal/x86_64/NSDate+AFDateHelperObjC.o
duplicate symbol _RSSDateFormatType in:
    /Users/TLL/Library/Developer/Xcode/DerivedData/AFDateHelperExtObjective-C-drnbulhrpdtwsbctmtvxzbnfjavn/Build/Intermediates/AFDateHelperExtObjective-C.build/Debug-iphonesimulator/AFDateHelperExtObjective-C.build/Objects-normal/x86_64/ViewController.o
    /Users/TLL/Library/Developer/Xcode/DerivedData/AFDateHelperExtObjective-C-drnbulhrpdtwsbctmtvxzbnfjavn/Build/Intermediates/AFDateHelperExtObjective-C.build/Debug-iphonesimulator/AFDateHelperExtObjective-C.build/Objects-normal/x86_64/NSDate+AFDateHelperObjC.o
duplicate symbol _ISO8601DateFormatType in:
    /Users/TLL/Library/Developer/Xcode/DerivedData/AFDateHelperExtObjective-C-drnbulhrpdtwsbctmtvxzbnfjavn/Build/Intermediates/AFDateHelperExtObjective-C.build/Debug-iphonesimulator/AFDateHelperExtObjective-C.build/Objects-normal/x86_64/ViewController.o
    /Users/TLL/Library/Developer/Xcode/DerivedData/AFDateHelperExtObjective-C-drnbulhrpdtwsbctmtvxzbnfjavn/Build/Intermediates/AFDateHelperExtObjective-C.build/Debug-iphonesimulator/AFDateHelperExtObjective-C.build/Objects-normal/x86_64/NSDate+AFDateHelperObjC.o
duplicate symbol _ISOFormatDateTime in:
    /Users/TLL/Library/Developer/Xcode/DerivedData/AFDateHelperExtObjective-C-drnbulhrpdtwsbctmtvxzbnfjavn/Build/Intermediates/AFDateHelperExtObjective-C.build/Debug-iphonesimulator/AFDateHelperExtObjective-C.build/Objects-normal/x86_64/ViewController.o
    /Users/TLL/Library/Developer/Xcode/DerivedData/AFDateHelperExtObjective-C-drnbulhrpdtwsbctmtvxzbnfjavn/Build/Intermediates/AFDateHelperExtObjective-C.build/Debug-iphonesimulator/AFDateHelperExtObjective-C.build/Objects-normal/x86_64/NSDate+AFDateHelperObjC.o
duplicate symbol _ISOFormatDateTimeMilliSec in:
    /Users/TLL/Library/Developer/Xcode/DerivedData/AFDateHelperExtObjective-C-drnbulhrpdtwsbctmtvxzbnfjavn/Build/Intermediates/AFDateHelperExtObjective-C.build/Debug-iphonesimulator/AFDateHelperExtObjective-C.build/Objects-normal/x86_64/ViewController.o
    /Users/TLL/Library/Developer/Xcode/DerivedData/AFDateHelperExtObjective-C-drnbulhrpdtwsbctmtvxzbnfjavn/Build/Intermediates/AFDateHelperExtObjective-C.build/Debug-iphonesimulator/AFDateHelperExtObjective-C.build/Objects-normal/x86_64/NSDate+AFDateHelperObjC.o
duplicate symbol _ISOFormatDateTimeSec in:
    /Users/TLL/Library/Developer/Xcode/DerivedData/AFDateHelperExtObjective-C-drnbulhrpdtwsbctmtvxzbnfjavn/Build/Intermediates/AFDateHelperExtObjective-C.build/Debug-iphonesimulator/AFDateHelperExtObjective-C.build/Objects-normal/x86_64/ViewController.o
    /Users/TLL/Library/Developer/Xcode/DerivedData/AFDateHelperExtObjective-C-drnbulhrpdtwsbctmtvxzbnfjavn/Build/Intermediates/AFDateHelperExtObjective-C.build/Debug-iphonesimulator/AFDateHelperExtObjective-C.build/Objects-normal/x86_64/NSDate+AFDateHelperObjC.o
duplicate symbol _ISOFormatYear in:
    /Users/TLL/Library/Developer/Xcode/DerivedData/AFDateHelperExtObjective-C-drnbulhrpdtwsbctmtvxzbnfjavn/Build/Intermediates/AFDateHelperExtObjective-C.build/Debug-iphonesimulator/AFDateHelperExtObjective-C.build/Objects-normal/x86_64/ViewController.o
    /Users/TLL/Library/Developer/Xcode/DerivedData/AFDateHelperExtObjective-C-drnbulhrpdtwsbctmtvxzbnfjavn/Build/Intermediates/AFDateHelperExtObjective-C.build/Debug-iphonesimulator/AFDateHelperExtObjective-C.build/Objects-normal/x86_64/DateFormat.o
duplicate symbol _ISOFormatYearMonth in:
    /Users/TLL/Library/Developer/Xcode/DerivedData/AFDateHelperExtObjective-C-drnbulhrpdtwsbctmtvxzbnfjavn/Build/Intermediates/AFDateHelperExtObjective-C.build/Debug-iphonesimulator/AFDateHelperExtObjective-C.build/Objects-normal/x86_64/ViewController.o
    /Users/TLL/Library/Developer/Xcode/DerivedData/AFDateHelperExtObjective-C-drnbulhrpdtwsbctmtvxzbnfjavn/Build/Intermediates/AFDateHelperExtObjective-C.build/Debug-iphonesimulator/AFDateHelperExtObjective-C.build/Objects-normal/x86_64/DateFormat.o
duplicate symbol _ISOFormatDate in:
    /Users/TLL/Library/Developer/Xcode/DerivedData/AFDateHelperExtObjective-C-drnbulhrpdtwsbctmtvxzbnfjavn/Build/Intermediates/AFDateHelperExtObjective-C.build/Debug-iphonesimulator/AFDateHelperExtObjective-C.build/Objects-normal/x86_64/ViewController.o
    /Users/TLL/Library/Developer/Xcode/DerivedData/AFDateHelperExtObjective-C-drnbulhrpdtwsbctmtvxzbnfjavn/Build/Intermediates/AFDateHelperExtObjective-C.build/Debug-iphonesimulator/AFDateHelperExtObjective-C.build/Objects-normal/x86_64/DateFormat.o
duplicate symbol _DotNetDateFormatType in:
    /Users/TLL/Library/Developer/Xcode/DerivedData/AFDateHelperExtObjective-C-drnbulhrpdtwsbctmtvxzbnfjavn/Build/Intermediates/AFDateHelperExtObjective-C.build/Debug-iphonesimulator/AFDateHelperExtObjective-C.build/Objects-normal/x86_64/ViewController.o
    /Users/TLL/Library/Developer/Xcode/DerivedData/AFDateHelperExtObjective-C-drnbulhrpdtwsbctmtvxzbnfjavn/Build/Intermediates/AFDateHelperExtObjective-C.build/Debug-iphonesimulator/AFDateHelperExtObjective-C.build/Objects-normal/x86_64/DateFormat.o
duplicate symbol _CustomDateFormatType in:
    /Users/TLL/Library/Developer/Xcode/DerivedData/AFDateHelperExtObjective-C-drnbulhrpdtwsbctmtvxzbnfjavn/Build/Intermediates/AFDateHelperExtObjective-C.build/Debug-iphonesimulator/AFDateHelperExtObjective-C.build/Objects-normal/x86_64/ViewController.o
    /Users/TLL/Library/Developer/Xcode/DerivedData/AFDateHelperExtObjective-C-drnbulhrpdtwsbctmtvxzbnfjavn/Build/Intermediates/AFDateHelperExtObjective-C.build/Debug-iphonesimulator/AFDateHelperExtObjective-C.build/Objects-normal/x86_64/DateFormat.o
duplicate symbol _AltRSSDateFormatType in:
    /Users/TLL/Library/Developer/Xcode/DerivedData/AFDateHelperExtObjective-C-drnbulhrpdtwsbctmtvxzbnfjavn/Build/Intermediates/AFDateHelperExtObjective-C.build/Debug-iphonesimulator/AFDateHelperExtObjective-C.build/Objects-normal/x86_64/ViewController.o
    /Users/TLL/Library/Developer/Xcode/DerivedData/AFDateHelperExtObjective-C-drnbulhrpdtwsbctmtvxzbnfjavn/Build/Intermediates/AFDateHelperExtObjective-C.build/Debug-iphonesimulator/AFDateHelperExtObjective-C.build/Objects-normal/x86_64/DateFormat.o
duplicate symbol _RSSDateFormatType in:
    /Users/TLL/Library/Developer/Xcode/DerivedData/AFDateHelperExtObjective-C-drnbulhrpdtwsbctmtvxzbnfjavn/Build/Intermediates/AFDateHelperExtObjective-C.build/Debug-iphonesimulator/AFDateHelperExtObjective-C.build/Objects-normal/x86_64/ViewController.o
    /Users/TLL/Library/Developer/Xcode/DerivedData/AFDateHelperExtObjective-C-drnbulhrpdtwsbctmtvxzbnfjavn/Build/Intermediates/AFDateHelperExtObjective-C.build/Debug-iphonesimulator/AFDateHelperExtObjective-C.build/Objects-normal/x86_64/DateFormat.o
duplicate symbol _ISO8601DateFormatType in:
    /Users/TLL/Library/Developer/Xcode/DerivedData/AFDateHelperExtObjective-C-drnbulhrpdtwsbctmtvxzbnfjavn/Build/Intermediates/AFDateHelperExtObjective-C.build/Debug-iphonesimulator/AFDateHelperExtObjective-C.build/Objects-normal/x86_64/ViewController.o
    /Users/TLL/Library/Developer/Xcode/DerivedData/AFDateHelperExtObjective-C-drnbulhrpdtwsbctmtvxzbnfjavn/Build/Intermediates/AFDateHelperExtObjective-C.build/Debug-iphonesimulator/AFDateHelperExtObjective-C.build/Objects-normal/x86_64/DateFormat.o
duplicate symbol _ISOFormatDateTime in:
    /Users/TLL/Library/Developer/Xcode/DerivedData/AFDateHelperExtObjective-C-drnbulhrpdtwsbctmtvxzbnfjavn/Build/Intermediates/AFDateHelperExtObjective-C.build/Debug-iphonesimulator/AFDateHelperExtObjective-C.build/Objects-normal/x86_64/ViewController.o
    /Users/TLL/Library/Developer/Xcode/DerivedData/AFDateHelperExtObjective-C-drnbulhrpdtwsbctmtvxzbnfjavn/Build/Intermediates/AFDateHelperExtObjective-C.build/Debug-iphonesimulator/AFDateHelperExtObjective-C.build/Objects-normal/x86_64/DateFormat.o
duplicate symbol _ISOFormatDateTimeMilliSec in:
    /Users/TLL/Library/Developer/Xcode/DerivedData/AFDateHelperExtObjective-C-drnbulhrpdtwsbctmtvxzbnfjavn/Build/Intermediates/AFDateHelperExtObjective-C.build/Debug-iphonesimulator/AFDateHelperExtObjective-C.build/Objects-normal/x86_64/ViewController.o
    /Users/TLL/Library/Developer/Xcode/DerivedData/AFDateHelperExtObjective-C-drnbulhrpdtwsbctmtvxzbnfjavn/Build/Intermediates/AFDateHelperExtObjective-C.build/Debug-iphonesimulator/AFDateHelperExtObjective-C.build/Objects-normal/x86_64/DateFormat.o
duplicate symbol _ISOFormatDateTimeSec in:
    /Users/TLL/Library/Developer/Xcode/DerivedData/AFDateHelperExtObjective-C-drnbulhrpdtwsbctmtvxzbnfjavn/Build/Intermediates/AFDateHelperExtObjective-C.build/Debug-iphonesimulator/AFDateHelperExtObjective-C.build/Objects-normal/x86_64/ViewController.o
    /Users/TLL/Library/Developer/Xcode/DerivedData/AFDateHelperExtObjective-C-drnbulhrpdtwsbctmtvxzbnfjavn/Build/Intermediates/AFDateHelperExtObjective-C.build/Debug-iphonesimulator/AFDateHelperExtObjective-C.build/Objects-normal/x86_64/DateFormat.o
ld: 22 duplicate symbols for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

到目前为止我尝试了什么:

  • 我发现没有重复声明。
  • 我发现没有错误导入“.h”或“.m”某处。
  • 未在Build Settings设置中使用“-Obj-C”

我的DateFormat.h:

#import <Foundation/Foundation.h>

NSString * const ISO8601DateFormatType = @"ISO8601";
NSString * const DotNetDateFormatType = @"DotNet";
NSString * const RSSDateFormatType = @"RSS";
NSString * const AltRSSDateFormatType = @"AltRSS";
NSString * const CustomDateFormatType = @"Custom";

NSString * const ISOFormatYear = @"yyyy";
NSString * const ISOFormatYearMonth = @"yyyy-MM"; // 1997-07
NSString * const ISOFormatDate = @"yyyy-MM-dd"; // 1997-07-16
NSString * const ISOFormatDateTime = @"yyyy-MM-dd'T'HH:mmZ"; // 1997-07-16T19:20+01:00
NSString * const ISOFormatDateTimeSec = @"yyyy-MM-dd'T'HH:mm:ssZ"; // 1997-07-16T19:20:30+01:00
NSString * const ISOFormatDateTimeMilliSec = @"yyyy-MM-dd'T'HH:mm:ss.SSSZ"; // 1997-07-16T19:20:30.45+01:00

@interface DateFormat : NSObject

+ (instancetype) ISODateFormat: (NSString *) isoFormat;
+ (instancetype) DotNetDateFormat;
+ (instancetype) RSSDateFormat;
+ (instancetype) AltRSSDateFormat;
+ (instancetype) CustomDateFormat: (NSString *) formatString;

@property (readonly) NSString *dateFormatType;
@property (readonly) NSString *formatDetails;

@end

2 个答案:

答案 0 :(得分:0)

您似乎已经两次添加了对AFDateHelper(以及NSDate上的附带类别)的引用。有时清洁可以解决这个问题。如果没有,则在导航器中选择该文件(AFDateHelper.m),取消选中其目标成员身份并再次尝试构建。如果它构建,则在项目的其他位置对文件进行第二次引用。最好

答案 1 :(得分:0)

您已使用以下内容声明了.h中的字符串:

NSString * const ...

这意味着导入.h的每个文件都声明了这些字符串的相同集合,并且最终会出现重复的符号。

您可以通过在.h extern中声明每个声明来解决这个问题 - 这意味着它只是声明在别处定义的变量的名称和类型 - 并删除初始化;然后在相应的.m中包含没有extern的声明和初始化。

另一种更短但更丑陋的解决方案是在.h static中进行所有声明并保留初始化。这种方法为每个.m提供了.h个自己的私有变量集。在空间上有点浪费,但在其他方面工作正常。

HTH