我正在使用 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。但是如果我添加了一个 iOS SDK 框架(如 MobileCoreServices),xctest
就会出现问题,给我报错:
Library not loaded: /System/Library/Frameworks/MobileCoreServices.framework/MobileCoreServices
在Xcode中,单元测试可以正常运行,在单元测试目标中包含$(PLATFORM_DIR)/Developer/Library/Frameworks
作为其框架搜索路径。
有人知道让xctest
找到iOS框架的正确方法吗?