XCTest不链接iOS框架

Luk*_*uke 8 xcode unit-testing ios xcrun xctest

我正在使用命令行运行iOS模拟器单元测试xctest.首先,我构建目标:

xcodebuild -project "build/MyApp.xcodeproj" -target "MyApp Unit Tests" -configuration "Debug" -sdk "iphonesimulator" build
Run Code Online (Sandbox Code Playgroud)

然后运行xctest测试包:

xcrun xctest "build/build/Debug-iphonesimulator/MyApp Unit Tests.xctest"
Run Code Online (Sandbox Code Playgroud)

这工作正常,可以链接/ System/Library/Frameworks中的框架,如安全性.但是xctest一旦我添加了像MobileCoreServices这样的iOS SDK框架,就会中断,给我:

Library not loaded: /System/Library/Frameworks/MobileCoreServices.framework/MobileCoreServices
Run Code Online (Sandbox Code Playgroud)

单元测试在Xcode中运行良好,单元测试目标包含$(PLATFORM_DIR)/Developer/Library/Frameworks在其框架搜索路径中.

有人知道xctest找到iOS框架的正确方法吗?

小智 0

测试目标需要能够在 MyApp 的构建产品中查找框架。您应该将框架搜索路径添加到测试目标:

$(CONFIGURATION_TEMP_DIR)/MyApp.build/DerivedSources
Run Code Online (Sandbox Code Playgroud)