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

phi*_*son 3 unit-testing objective-c 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)
Run Code Online (Sandbox Code Playgroud)

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

有想法该怎么解决这个吗?

Jon*_*eid 5

从阅读"我决定是时候写一些测试",我猜你已经有一段时间了,因为你创建了这个项目.也许......

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

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