0

(If you have an idea, whatever it may be, please post an answer, I will give you +1 even if it didn't solve my case :))

Just got this error.

I googled it and found no solution so far.

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)

What I tried so far:

  • I found no duplicate declaration.
  • I found no wrong import ".h" or ".m" somewhere.
  • Didn't use "-Obj-C" in Build Settings

My 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
Community
  • 1
  • 1
  • Could there be double declarations of `ISOFormatDateTimeSec`, one in `NSDate+AFDateHelperObjC` and the other in `DateFormat.h`? – Larme Apr 18 '16 at 08:19

2 Answers2

0

You appear to have added references to AFDateHelper (and an accompanying category on NSDate) twice. Sometimes a clean can solve this. If not then select that file (AFDateHelper.m) in the Navigator, uncheck its membership to the target and try to build again. If it builds then there is a second reference to the file somewhere else in the project. Best

Jef
  • 4,728
  • 2
  • 25
  • 33
  • Clean doesn't work. Unchecking the reference didn't work :( –  Apr 18 '16 at 07:21
  • Still gave you +1 for answering. –  Apr 18 '16 at 07:42
  • Check the header file, it should not have a checkmark against 'target membership' if it does then that can cause this too – Jef Apr 18 '16 at 07:42
  • This was a library in Swift that I converted to Objective-C. –  Apr 18 '16 at 07:45
  • Ah ! Are you sure the swift files are removed? Swift generates a bridging header which you can't see in the navigator.. – Jef Apr 18 '16 at 07:46
  • Where can I find the bridging header ? –  Apr 18 '16 at 07:47
  • I must say though that I created an empty Objective-C project, then copy pasted the Swift code in it and converted it. –  Apr 18 '16 at 07:48
  • I'm not 100% sure sorry. Check your build phases, make sure there's only implementation files (.m .c .mm etc) in the compile sources phase and check also the copy files phase for any files that need not be there – Jef Apr 18 '16 at 07:50
  • Checked, no swift bridging header. –  Apr 18 '16 at 07:53
0

You have declared strings in you .h using:

NSString * const ...

That means every file that imports the .h declares the same set of these strings, and you end up with duplicate symbols.

You can address this by making each declaration in the .h extern - meaning it is just declaring the name and type of a variable defined elsewhere - and removing the initialisation; and then in the corresponding .m include the declarations without the extern and with the initialisation.

An alternative shorter, but uglier, solution is to make all the declarations in the .h static and leave the initialisation. This approach gives every .m that includes the .h it's own private set of variables. A bit wasteful on space, but otherwise works fine.

HTH

CRD
  • 52,522
  • 5
  • 70
  • 86