添加CloudKit功能后XCTest失败

启用CloudKit后,我的测试无法运行,显然是因为无法对测试包进行正确的代码签名:

The bundle “XXXTests” couldn’t be loaded because it is damaged or missing necessary resources. Try reinstalling the bundle.
2020-01-06 09:11:40.551130+0100 XXX[2581:20975 (dlopen_preflight(/Users/xxx/library/Developer/Xcode/DerivedData/XXX-gznytogyqukfvnawlueveokdvdrw/Build/Products/Debug/XXX.app/Contents/PlugIns/XXXTests.xctest/Contents/MacOS/XXXTests): no suitable image found.  Did find:
/Users/xxx/library/Developer/Xcode/DerivedData/XXX-gznytogyqukfvnawlueveokdvdrw/Build/Products/Debug/XXX.app/Contents/PlugIns/XXXTests.xctest/Contents/MacOS/XXXTests: code signature invalid for '/Users/xxx/library/Developer/Xcode/DerivedData/XXX-gznytogyqukfvnawlueveokdvdrw/Build/Products/Debug/XXX.app/Contents/PlugIns/XXXTests.xctest/Contents/MacOS/XXXTests')

我已经尝试清理构建文件夹,删除派生数据文件夹,手动下载配置文件,在网上搜索类似问题并尝试提出解决方案,甚至重新启动Mac并重新集成Cocoapods,尽管我认为这完全无关。

我想念什么?

dongchenxiapril 回答:添加CloudKit功能后XCTest失败

通过给测试目标自己的权利文件解决了该问题,该文件没有任何CloudKit引用。同样,对于测试目标,我使用NSPersistentContainer而不是NSPersistentCloudKitContainer。换句话说:应用程序目标正在使用CloudKit,而测试目标却没有。这样一来,在启用应用程序本身通过iCloud进行同步的同时,测试再次成功。

本文链接:https://www.f2er.com/2814454.html

大家都在问