使用 xcodebuild 运行测试而无需签名

Cry*_*thm 9 macos codesign xctest

我正在尝试做什么

我正在尝试在XCTest没有代码签名的情况下运行在框架中编写的多个测试,目的是不必处理在 CI 上导入代码签名身份的麻烦。

我尝试过的

我已经删除了开发团队,并将应用程序和测试目标的签名证书设置为“签名以在本地运行”。建筑与

xcodebuild build-for-testing -scheme <my scheme>
Run Code Online (Sandbox Code Playgroud)

适用于 CI 和本地,但尝试运行测试

xcodebuild test-without-building -scheme <my scheme>
Run Code Online (Sandbox Code Playgroud)

大约 10 秒后失败并出现错误<name> (83559) encountered an error (Failed to load the test bundle.<test binary> not valid for use in process: mapped file has no Team ID and is not a platform binary (signed with custom identity or adhoc?下面几行可以更清楚地说明这个问题。似乎 macOS 不喜欢未签名的测试包并拒绝加载它。

像这样运行测试命令:

 xcodebuild test-without-building -xctestrun /Users/vinkwok/Library/Developer/Xcode/DerivedData/ChessFrontend-carjpisbuprsabeulpsycoxjqjea/Build/Products/ChessFrontend_macosx13.0-arm64.xctestrun -destination "platform=macOS,id=<id>,arch=arm64"
Run Code Online (Sandbox Code Playgroud)

抛出以下错误:

Early unexpected exit, operation never finished bootstrapping - no restart will be attempted. (Underlying Error: The test runner exited with code 1 before checking in. ...)
Run Code Online (Sandbox Code Playgroud)

看起来好像发生了相同的测试包错误,只不过这次没有打印出来,因为测试运行程序根本无法启动。

我还尝试使用我的开发证书签署测试包codesign,但这只是导致xcodebuild test-without-building抱怨该包缺少开发团队。

任何人都可以为我指明如何在 CI 环境上运行测试的正确方向,而无需处理签名和代码签名身份的麻烦吗?答案将不胜感激!