在向XCode 5项目添加测试时会产生麻烦

时间:2013-12-27 03:45:20

标签: objective-c unit-testing xcode5

我决定是时候为我的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)

此处是我的“框架搜索路径”设置的屏幕截图:http://cl.ly/T7gV

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

3 个答案:

答案 0 :(得分:5)

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

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

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

答案 1 :(得分:0)

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

我愤怒地回到了项目设置,并确认没有报价被转义,但决定删除" $(SDKROOT)"周围的报价。等等。

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

首先尝试,希望这有助于某人!

答案 2 :(得分:0)

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