每次运行超过3个场景的代码时,我都会收到Apple Mach-O链接器错误。我搜索了这个,我尝试做几乎所有人说的话:
产品>清洁
产品>清理构建文件夹
删除派生数据
但它们似乎都不适用于我的情况。我再次构建时仍然会收到错误。
这是完整的错误:
Ld /Users/rohankalantri/Library/Developer/Xcode/DerivedData/FinalTest(1)-actqlzklrbebyyfwvakdqnhcnozz/Build/Products/Debug-iphonesimulator/FinalTest(1).app/FinalTest(1) normal x86_64
cd "/Volumes/MacData/xCode/FinalTest(1)/FinalTest(1)"
export IPHONEOS_DEPLOYMENT_TARGET=8.1
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/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/iPhoneSimulator8.1.sdk -L/Users/rohankalantri/Library/Developer/Xcode/DerivedData/FinalTest(1)-actqlzklrbebyyfwvakdqnhcnozz/Build/Products/Debug-iphonesimulator -F/Users/rohankalantri/Library/Developer/Xcode/DerivedData/FinalTest(1)-actqlzklrbebyyfwvakdqnhcnozz/Build/Products/Debug-iphonesimulator -filelist /Users/rohankalantri/Library/Developer/Xcode/DerivedData/FinalTest(1)-actqlzklrbebyyfwvakdqnhcnozz/Build/Intermediates/FinalTest(1).build/Debug-iphonesimulator/FinalTest(1).build/Objects-normal/x86_64/FinalTest(1).LinkFileList -Xlinker -rpath -Xlinker @executable_path/Frameworks -Xlinker -objc_abi_version -Xlinker 2 -fobjc-arc -fobjc-link-runtime -Xlinker -no_implicit_dylibs -mios-simulator-version-min=8.1 -Xlinker -dependency_info -Xlinker /Users/rohankalantri/Library/Developer/Xcode/DerivedData/FinalTest(1)-actqlzklrbebyyfwvakdqnhcnozz/Build/Intermediates/FinalTest(1).build/Debug-iphonesimulator/FinalTest(1).build/Objects-normal/x86_64/FinalTest(1)_dependency_info.dat -o /Users/rohankalantri/Library/Developer/Xcode/DerivedData/FinalTest(1)-actqlzklrbebyyfwvakdqnhcnozz/Build/Products/Debug-iphonesimulator/FinalTest(1).app/FinalTest(1)
duplicate symbol _level in:
/Users/rohankalantri/Library/Developer/Xcode/DerivedData/FinalTest(1)-actqlzklrbebyyfwvakdqnhcnozz/Build/Intermediates/FinalTest(1).build/Debug-iphonesimulator/FinalTest(1).build/Objects-normal/x86_64/easyLevel.o
/Users/rohankalantri/Library/Developer/Xcode/DerivedData/FinalTest(1)-actqlzklrbebyyfwvakdqnhcnozz/Build/Intermediates/FinalTest(1).build/Debug-iphonesimulator/FinalTest(1).build/Objects-normal/x86_64/mediumLevel.o
duplicate symbol _durationTime in:
/Users/rohankalantri/Library/Developer/Xcode/DerivedData/FinalTest(1)-actqlzklrbebyyfwvakdqnhcnozz/Build/Intermediates/FinalTest(1).build/Debug-iphonesimulator/FinalTest(1).build/Objects-normal/x86_64/easyLevel.o
/Users/rohankalantri/Library/Developer/Xcode/DerivedData/FinalTest(1)-actqlzklrbebyyfwvakdqnhcnozz/Build/Intermediates/FinalTest(1).build/Debug-iphonesimulator/FinalTest(1).build/Objects-normal/x86_64/mediumLevel.o
duplicate symbol _delayTime in:
/Users/rohankalantri/Library/Developer/Xcode/DerivedData/FinalTest(1)-actqlzklrbebyyfwvakdqnhcnozz/Build/Intermediates/FinalTest(1).build/Debug-iphonesimulator/FinalTest(1).build/Objects-normal/x86_64/easyLevel.o
/Users/rohankalantri/Library/Developer/Xcode/DerivedData/FinalTest(1)-actqlzklrbebyyfwvakdqnhcnozz/Build/Intermediates/FinalTest(1).build/Debug-iphonesimulator/FinalTest(1).build/Objects-normal/x86_64/mediumLevel.o
duplicate symbol _firstTime in:
/Users/rohankalantri/Library/Developer/Xcode/DerivedData/FinalTest(1)-actqlzklrbebyyfwvakdqnhcnozz/Build/Intermediates/FinalTest(1).build/Debug-iphonesimulator/FinalTest(1).build/Objects-normal/x86_64/easyLevel.o
/Users/rohankalantri/Library/Developer/Xcode/DerivedData/FinalTest(1)-actqlzklrbebyyfwvakdqnhcnozz/Build/Intermediates/FinalTest(1).build/Debug-iphonesimulator/FinalTest(1).build/Objects-normal/x86_64/mediumLevel.o
ld: 4 duplicate symbols for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
我也明白了:
ld:4个用于体系结构x86_64的重复符号
我做错了吗?我该如何解决这个问题呢? PS:我使用的是Xcode 6 Version 6.1.1(6A2008a)和Objective C。
答案 0 :(得分:0)
您是否有easyLevel
和mediumLevel
的班级文件?它们似乎被多次编译,这导致您的错误duplicate symbol
。
您可以在“项目设置”(文件列表中的顶部条目,以项目命名)>中进行检查。在左侧列表中选择您的目标>在顶部的标签栏中选择“Build Phases”> “编译来源”。然后确保每个文件源文件只存在一次。
您可以在Apple’s documentation “Controlling How an Individual File Is Compiled”
中看到此截图答案 1 :(得分:0)
通常当我遇到这种情况时,我发现我导入的是.m文件而不是.h文件。
答案 2 :(得分:0)
听起来有点像非静态全局变量在头文件中声明并导入到easyLevel和mediumLevel。