-1

根据教程构建 iOS 应用程序,我收到以下消息:

ld /Users/EvanBresnan/Library/Developer/Xcode/DerivedData/FirstGame-ekyyaqwhjsjimddxggwkkkgblylu/Build/Products/Debug-iphonesimulator/FirstGame.app/FirstGame normal i386
    cd /Users/EvanBresnan/Documents/Xcode/FirstGame
    导出 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/FirstGamedat -o /Users/EvanBresnan/Library/Developer/Xcode/DerivedData/FirstGame-ekyyaqwhjsjimddxggwkkkgblylu/Build/Products/Debug-iphonesimulator/FirstGame.app/FirstGamedat -o /Users/EvanBresnan/Library/Developer/Xcode/DerivedData/FirstGame-ekyyaqwhjsjimddxggwkkkgblylu/Build/Products/Debug-iphonesimulator/FirstGame.app/FirstGame

重复符号 _HighScoreNumber 在:
    /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:架构 i386 的 1 个重复符号
clang:错误:链接器命令失败,退出代码为 1(使用 -v 查看调用)
4

2 回答 2

1

从错误信息

duplicate symbol _HighScoreNumber in:...

我猜您在两个文件中声明了全局变量 _HighScoreNumber(或者可能在两个文件中导入的标头中)。检查 _HighScoreNumber 的声明位置和方式,并将其移动到正确的位置。

于 2016-02-05T22:45:11.507 回答
0

我最近面临同样的问题。我知道E. Brez得到了答案,但为了帮助可能遇到与我相同问题的其他人。
根据我的应用程序流程,我正在使用与打印机相关的第三方类进行打印。ImagePrintViewController为了使用它,我在我的两个文件中分别创建了该类的对象,PrintResultViewController并将所需的数据传递给它。

在我的场景中,我在我_printerSetup的两个文件/Library/Developer/Xcode/DerivedData/../x86_64/ImagePrintViewController.o/Library/Developer/Xcode/DerivedData/../x86_64/PrintResultViewController.o.
我在我的两个文件中都搜索了上述变量名。但我找不到那个。

经过长时间的搜索后,我想到了删除我的第二个文件的引用,即在我的第一个文件中合并代码之后BRPrintResultViewController.hBRPrintResultViewController.m

有了这个,我找到了我的解决方案,并且我的代码在此之后运行良好。

于 2017-03-06T10:24:17.790 回答