我正在使用xctest在命令行上运行iOS模拟器单元测试.首先,我构建目标:
xcodebuild -project "build/MyApp.xcodeproj" -target "MyApp Unit Tests" -configuration "Debug" -sdk "iphonesimulator" build
然后在测试包上运行xctest:
xcrun xctest "build/build/Debug-iphonesimulator/MyApp Unit Tests.xctest"
这样可以正常工作,并且可以链接/ System / Library / Frameworks中的框架,例如Security.但是一旦我添加了像MobileCoreServices这样的iOS SDK框架,xctest就会中断,这给了我:
Library not loaded: /System/Library/Frameworks/MobileCoreServices.framework/MobileCoreServices
单元测试在Xcode中运行良好,单元测试目标在其框架搜索路径中包含$(PLATFORM_DIR)/ Developer / Library / Frameworks.
有人知道让xctest找到iOS框架的正确方法吗?
解决方法
测试目标需要能够在MyApp的构建产品中查找框架.您应该向测试目标添加框架搜索路径:
$(CONFIGURATION_TEMP_DIR)/MyApp.build/DerivedSources