【问题标题】:build troubles when adding tests to XCode 5 project向 XCode 5 项目添加测试时出现问题
【发布时间】:2014-01-14 16:12:09
【问题描述】:

我决定是时候为我的 iPhone 应用程序编写一些测试了。不幸的是,这并不顺利。我创建了一个新的测试类,但得到以下错误。看起来它正在向我拉入 OS X 库,但我不知道为什么....

Ld /Users/philswenson/Library/Developer/Xcode/DerivedData/3rdRevolution-crkklmdwurdjtrbjvjedcqqeoyvk/Build/Products/Debug-iphonesimulator/3rdRevolutionTests.octest/3rdRevolutionTests normal i386
cd /Users/philswenson/dev/3rdRev/3R_iOS
setenv IPHONEOS_DEPLOYMENT_TARGET 7.0
setenv 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 i386 -bundle -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.0.sdk -L/Users/philswenson/Library/Developer/Xcode/DerivedData/3rdRevolution-crkklmdwurdjtrbjvjedcqqeoyvk/Build/Products/Debug-iphonesimulator -F/Users/philswenson/Library/Developer/Xcode/DerivedData/3rdRevolution-crkklmdwurdjtrbjvjedcqqeoyvk/Build/Products/Debug-iphonesimulator -F/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.0.sdk/Developer/Library/Frameworks -F/Applications/Xcode.app/Contents/Developer/Library/Frameworks -filelist /Users/philswenson/Library/Developer/Xcode/DerivedData/3rdRevolution-crkklmdwurdjtrbjvjedcqqeoyvk/Build/Intermediates/3rdRevolution.build/Debug-iphonesimulator/3rdRevolutionTests.build/Objects-normal/i386/3rdRevolutionTests.LinkFileList -bundle_loader /Users/philswenson/Library/Developer/Xcode/DerivedData/3rdRevolution-crkklmdwurdjtrbjvjedcqqeoyvk/Build/Products/Debug-iphonesimulator/3rdRevolution.app/3rdRevolution -Xlinker -objc_abi_version -Xlinker 2 -fobjc-arc -fobjc-link-runtime -Xlinker -no_implicit_dylibs -mios-simulator-version-min=7.0 -framework SenTestingKit -framework UIKit -framework Foundation -Xlinker -dependency_info -Xlinker /Users/philswenson/Library/Developer/Xcode/DerivedData/3rdRevolution-crkklmdwurdjtrbjvjedcqqeoyvk/Build/Intermediates/3rdRevolution.build/Debug-iphonesimulator/3rdRevolutionTests.build/Objects-normal/i386/3rdRevolutionTests_dependency_info.dat -o /Users/philswenson/Library/Developer/Xcode/DerivedData/3rdRevolution-crkklmdwurdjtrbjvjedcqqeoyvk/Build/Products/Debug-iphonesimulator/3rdRevolutionTests.octest/3rdRevolutionTests

Undefined symbols for architecture i386:
  "_OBJC_CLASS_$_XCTestCase", referenced from:
      _OBJC_CLASS_$_IsoDateTest in IsoDateTest.o
  "_OBJC_METACLASS_$_XCTestCase", referenced from:
      _OBJC_METACLASS_$_IsoDateTest in IsoDateTest.o
  "__XCTFailureFormat", referenced from:
      -[IsoDateTest testExample] in IsoDateTest.o
  "__XCTFailureHandler", referenced from:
      -[IsoDateTest testExample] in IsoDateTest.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

这是我的框架搜索路径设置的屏幕截图:

关于如何解决这个问题的任何想法?

【问题讨论】:

    标签: objective-c unit-testing xcode5


    【解决方案1】:

    从阅读“我决定是时候编写一些测试了”,我猜你已经有一段时间没有创建这个项目了。所以也许……

    • 您使用 Xcode 4 创建了项目。测试目标将使用 SenTestingKit。
    • 您使用 Xcode 5 添加了 IsoDateTest.m。最新的文件模板使用 XCTest。

    检查测试目标的构建设置下的库列表。将 SenTestingKit.framework 替换为 XCTest.framework。

    【讨论】:

      【解决方案2】:

      升级到 XCTest 后我遇到了类似的问题,我做的第一件事就是确保我的框架搜索路径中没有一个引号被转义。他们确实没有,但我继续收到编译错误。在查看了实际的编译命令后,我注意到它 仍然无缘无故地转义引号,从而导致我的 Frameworks 目录路径无效。

      我一怒之下回到了项目设置,确认没有引号被转义,但决定去掉“$(SDKROOT)”等周围的引号。

      产品 -> 清洁 产品 -> 测试

      第一次尝试,希望这对某人有帮助!

      【讨论】:

        【解决方案3】:

        按照this answer 删除目标框架设置中的反斜杠对我有用。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2013-09-29
          • 2011-12-15
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2020-11-18
          • 1970-01-01
          相关资源
          最近更新 更多