Search code examples
iosobjective-clinker-errorsduplicate-symbol

Duplicate Symbol - linker command failed with exit code 1 (use -v to see invocation)?


Building an iOS app off a tutorial and I get this message:

Ld /Users/EvanBresnan/Library/Developer/Xcode/DerivedData/FirstGame-ekyyaqwhjsjimddxggwkkkgblylu/Build/Products/Debug-iphonesimulator/FirstGame.app/FirstGame normal i386
    cd /Users/EvanBresnan/Documents/Xcode/FirstGame
    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 i386 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk -L/Users/EvanBresnan/Library/Developer/Xcode/DerivedData/FirstGame-ekyyaqwhjsjimddxggwkkkgblylu/Build/Products/Debug-iphonesimulator -F/Users/EvanBresnan/Library/Developer/Xcode/DerivedData/FirstGame-ekyyaqwhjsjimddxggwkkkgblylu/Build/Products/Debug-iphonesimulator -filelist /Users/EvanBresnan/Library/Developer/Xcode/DerivedData/FirstGame-ekyyaqwhjsjimddxggwkkkgblylu/Build/Intermediates/FirstGame.build/Debug-iphonesimulator/FirstGame.build/Objects-normal/i386/FirstGame.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/EvanBresnan/Library/Developer/Xcode/DerivedData/FirstGame-ekyyaqwhjsjimddxggwkkkgblylu/Build/Intermediates/FirstGame.build/Debug-iphonesimulator/FirstGame.build/Objects-normal/i386/FirstGame_dependency_info.dat -o /Users/EvanBresnan/Library/Developer/Xcode/DerivedData/FirstGame-ekyyaqwhjsjimddxggwkkkgblylu/Build/Products/Debug-iphonesimulator/FirstGame.app/FirstGame

duplicate symbol _HighScoreNumber in:
    /Users/EvanBresnan/Library/Developer/Xcode/DerivedData/FirstGame-ekyyaqwhjsjimddxggwkkkgblylu/Build/Intermediates/FirstGame.build/Debug-iphonesimulator/FirstGame.build/Objects-normal/i386/ViewController.o
    /Users/EvanBresnan/Library/Developer/Xcode/DerivedData/FirstGame-ekyyaqwhjsjimddxggwkkkgblylu/Build/Intermediates/FirstGame.build/Debug-iphonesimulator/FirstGame.build/Objects-normal/i386/Game.o
ld: 1 duplicate symbol for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Solution

  • From error message

    duplicate symbol _HighScoreNumber in:...
    

    I'd guess that you declared global variable _HighScoreNumber in two files (or may be in a header that's imported in two files). Check where and how _HighScoreNumber is declared and move it to the right place.