我正在从事 iOS 开发的 CI/CD 工作,但我遇到了 XCUITest 的问题。我想构建项目进行测试,然后将 zip 上传到 pCloudy 服务来运行测试。 我尝试使用 fastlane 运行它,目标是“generic/platform=iOS”。 但它显示错误:
Unable to find a destination matching the provided destination specifier:
{ generic:1, platform:iOS }
看起来 xcodebuild 接受目标模拟器或真实设备已连接到 Mac
这是我的脚本:
run_tests(
destination: 'generic/platform=iOS',
# I also tried with devices param
# devices: ['generic/platform=iOS']
scheme: "appUITests",
configuration: "Dev",
derived_data_path: "derived_data",
build_for_testing: true,
clean: true,
)
xcodebuild 脚本显示在终端上:
set -o pipefail && env NSUnbufferedIO=YES xcodebuild -workspace ./app.xcworkspace -scheme appUITests -configuration Dev -derivedDataPath derived_data -destination 'generic/platform=iOS' clean build-for-testing | tee '/Users/xx/Library/Logs/scan/app-app.log' | xcpretty --report junit --output '/Users/xx/workspace/app-ios/fastlane/test_output/report.junit' --report junit --output '/var/folders/p_/yqdfspgd23x6w10wpdpqw4cm0000gn/T/junit_report20230804-56805-1onkrcb'
有人知道我们如何构建用于真实设备测试的套件吗?
我最终在 Fastlane 上使用了 sh 方法
sh("set -o pipefail && xcodebuild -workspace ./app.xcworkspace -scheme appUITests -derivedDataPath ./derived_data -destination 'generic/platform=iOS' build-for-testing | tee './App-appUITests.log' | xcbeautify")