首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >API滥用:尝试用Assets.xcassets序列化非拥有协调器上的存储访问。

API滥用:尝试用Assets.xcassets序列化非拥有协调器上的存储访问。
EN

Stack Overflow用户
提问于 2021-06-17 15:26:43
回答 1查看 330关注 0票数 2

你好,我收到一个错误,如果我实现SwiftUI到我的应用程序,这是基于故事板在目前。我创建了一个SwiftUI文件,我还可以在我的应用程序中显示我的SwiftUI视图。但是,如果我试图在XCode中预览我的SwiftUI文件,我会得到以下错误:

代码语言:javascript
复制
Showing All Messages
CompileAssetCatalog /Users/n0name/Library/Developer/Xcode/DerivedData/MediaApp-auxosshpupveyzcyqpenlftpfxti/Build/Intermediates.noindex/Previews/MediaApp/Products/Debug-iphonesimulator/MediaApp.app /Users/n0name/Desktop/sevdaDev/MediaApp/MediaApp/MediaApp/Assets.xcassets (in target 'MediaApp' from project 'MediaApp')
    cd /Users/n0name/Desktop/sevdaDev/MediaApp/MediaApp
    /Applications/Xcode.app/Contents/Developer/usr/bin/actool --output-format human-readable-text --notices --warnings --export-dependency-info /Users/n0name/Library/Developer/Xcode/DerivedData/MediaApp-auxosshpupveyzcyqpenlftpfxti/Build/Intermediates.noindex/Previews/MediaApp/Intermediates.noindex/MediaApp.build/Debug-iphonesimulator/MediaApp.build/assetcatalog_dependencies --output-partial-info-plist /Users/n0name/Library/Developer/Xcode/DerivedData/MediaApp-auxosshpupveyzcyqpenlftpfxti/Build/Intermediates.noindex/Previews/MediaApp/Intermediates.noindex/MediaApp.build/Debug-iphonesimulator/MediaApp.build/assetcatalog_generated_info.plist --app-icon AppIcon --compress-pngs --enable-on-demand-resources YES --development-region en --target-device iphone --target-device ipad --minimum-deployment-target 13.4 --platform iphonesimulator --compile /Users/n0name/Library/Developer/Xcode/DerivedData/MediaApp-auxosshpupveyzcyqpenlftpfxti/Build/Intermediates.noindex/Previews/MediaApp/Products/Debug-iphonesimulator/MediaApp.app /Users/n0name/Desktop/sevdaDev/MediaApp/MediaApp/MediaApp/Assets.xcassets

2021-06-17 15:51:57.997 ibtoold[28465:1115997] DEBUG: Added to environment: {
    TMPDIR = "/var/folders/5v/p26rjcc50bxcjkcj8h4z2tq40000gn/T/C9D47C23-18B9-48A8-BE11-80115C363851";
}
CoreData: error:  API Misuse: Attempt to serialize store access on non-owning coordinator (PSC = 0x7fe52157bef0, store PSC = 0x0)
CoreData: error:  API Misuse: Attempt to serialize store access on non-owning coordinator (PSC = 0x7fe52157bef0, store PSC = 0x0)
2021-06-17 15:52:09.204 IBCocoaTouchImageCatalogTool[28466:1116234] *** Assertion failure in -[CoreThemeDocument metadatumForKey:], CoreThemeDocument.m:8011
2021-06-17 15:52:09.205 IBCocoaTouchImageCatalogTool[28466:1116234] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[CoreThemeDocument metadatumForKey] expects exactly one persistent store, but got 0.'
*** First throw call stack:
(
    0   CoreFoundation                      0x00007fff20422fba __exceptionPreprocess + 242
    1   libobjc.A.dylib                     0x00007fff20193ff5 objc_exception_throw + 48
    2   CoreFoundation                      0x00007fff20422de3 +[NSException raise:format:] + 0
    3   Foundation                          0x00007fff207748e7 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 191
    4   CoreThemeDefinition                 0x00007fff4cc7b7b5 -[CoreThemeDocument metadatumForKey:] + 205
    5   CoreThemeDefinition                 0x00007fff4cc7ca4b -[CoreThemeDocument allowsExtendedRangePixelFormats] + 29
    6   CoreThemeDefinition                 0x00007fff4cca1c1e -[TDSimpleArtworkRenditionSpec createCSIRepresentationWithCompression:colorSpaceID:document:] + 5410
    7   CoreThemeDefinition                 0x00007fff4ccac5f0 __34-[TDRenditionsDistiller _distill:]_block_invoke + 120
    8   CoreData                            0x00007fff250d323a developerSubmittedBlockToNSManagedObjectContextPerform + 154
    9   libdispatch.dylib                   0x00007fff201078df _dispatch_client_callout + 8
    10  libdispatch.dylib                   0x00007fff2010de15 _dispatch_lane_serial_drain + 715
    11  libdispatch.dylib                   0x00007fff2010e98c _dispatch_lane_invoke + 400
    12  libdispatch.dylib                   0x00007fff20118f81 _dispatch_workloop_worker_thread + 772
    13  libsystem_pthread.dylib             0x00007fff6034045d _pthread_wqthread + 314
    14  libsystem_pthread.dylib             0x00007fff6033f42f start_wqthread + 15
)
libc++abi: terminating with uncaught exception of type NSException

问题是我不知道为什么我会犯这个错误。如果我在模拟器上运行我的应用程序,我不会看到这样的错误。这个错误不发生在模拟器中,嗯?

上面的代码发生在日志中的步骤“显示所有消息CompileAssetCatalog"中。因为错误发生在这个步骤中,所以我认为它可能与我正在使用的资产(图像和矢量图形)有关。因此,我删除了除"AppIcon“之外的所有资产文件,并试图再次在XCode中运行预览,并且它确实工作了!!。但是,我不知道为什么我的资产与"NSObjectManager“或"PersistentContainer”"CoreData“和其他线程问题有关,在这些问题中,如果我搜索相同的错误,就会重定向。例如,其中一篇文章是:FetchedResultsController Swift 3 API Misuse: Attempt to serialize store access on non-owning coordinator

但我不使用复杂的东西,如“持久性容器”。我只使用我的userDefaults中的一些键,这些键被保存在那里并被检索。我也使用Firebase。老实说,我对线程和并发不太了解。那么,有人能解释我为什么会发生这个错误,为什么我会有这样奇怪的行为?为什么我的简单图像和向量资产会导致这样的问题?

我问我的一位同事,如果她尝试打开一个新创建的SwiftUI视图的预览,她也会得到相同的结果。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-06-17 19:18:37

当我第一次读到这个问题时,我没有意识到这是一个编译器错误--我以为这是在应用程序运行时发生的。

当编译器有这样的错误,表示崩溃时,它就是编译器中的一个bug。一直都是。那是不应该发生的。从您的评论中可以看出,您的JSON文件触发了这个bug。我不知道这个JSON文件是什么奇怪的地方,还是Xcode不喜欢在资产目录中使用JSON。无论如何,这都是一个Xcode错误,因为在最坏的情况下,Xcode应该告诉您不要将JSON文件放在那里,而不是这样做。

很高兴听到你找到了解决办法。这不是你能真正解决的问题,但如果你的解决办法能满足你的需要,那就足够了。不过苹果可以解决这个问题,所以我建议你访问https://feedbackassistant.apple.com,并对此提交一个bug。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68022299

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档