启用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,尽管我认为这完全无关。
我想念什么?
NSPersistentContainer
而不是NSPersistentCloudKitContainer
。换句话说:应用程序目标正在使用CloudKit,而测试目标却没有。这使测试能够再次成功,同时使应用程序本身可以通过iCloud进行同步。