我正在使用 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。但是 xctest
在我添加 iOS SDK 框架(如 MobileCoreServices)后立即中断,给我:
Library not loaded: /System/Library/Frameworks/MobileCoreServices.framework/MobileCoreServices
单元测试在 Xcode 中运行良好,单元测试目标在其框架搜索路径中包含 $(PLATFORM_DIR)/Developer/Library/Frameworks
。
有人知道让 xctest
找到 iOS 框架的正确方法吗?
最佳答案
测试目标需要能够在 MyApp 的构建产品中寻找框架。您应该将框架搜索路径添加到测试目标:
$(CONFIGURATION_TEMP_DIR)/MyApp.build/DerivedSources
关于ios - XCTest 不链接 iOS 框架,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32633647/