API 误用:尝试在非拥有协调器上序列化存储访问 - 使用 Assets.xcassets
API Misuse: Attempt to serialize store access on non-owning coordinator - with Assets.xcassets
你好,如果我在目前基于情节提要的应用程序中实现 SwiftUI,我会收到错误消息。我制作了一个 SwiftUI 文件,我还可以在我的应用程序中显示我的 SwiftUI 视图。但是,如果我尝试在我的 SwiftUI 文件的 XCode 内进行预览,我会收到以下错误:
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”有关" 和其他线程问题,如果我搜索相同的错误,我将重定向这些问题。例如,其中一个帖子是这样的:
但我不使用诸如“持久性容器”之类的复杂事物。我只在我的 userDefaults 中使用一些键,这些键被保存在那里并被检索。我也使用 Firebase。老实说,我对线程和并发了解不多。
那么有人可以向我解释为什么会出现这个错误以及为什么我会出现这样的奇怪行为吗?为什么我的简单图像和矢量资源会出现这样的问题????
我问过我的一位同事,她也从事同一个项目,如果她尝试打开新创建的 SwiftUI 视图的预览,她会得到相同的结果。
当我第一次阅读这个问题时,我没有意识到这是一个 编译器 错误——我以为它是在应用 运行 时发生的。
当编译器出现这样的错误时,表明发生了崩溃,这是编译器中的错误。总是。那永远不应该发生。从您的评论看来,您的 JSON 文件似乎触发了此错误。我不知道 JSON 文件是否有些奇怪,或者 Xcode 不喜欢在资产目录中包含 JSON。不管怎样,这是一个 Xcode 错误,因为在最坏的情况下 Xcode 应该告诉你不要把 JSON 文件放在那里而不是这样做。
很高兴听到您找到了解决方法。这不是您可以实际修复的问题,但如果您的变通方法满足您的需要,那么就足够了。 Apple 可以修复它,所以我建议访问 https://feedbackassistant.apple.com 并提交有关此问题的错误。
你好,如果我在目前基于情节提要的应用程序中实现 SwiftUI,我会收到错误消息。我制作了一个 SwiftUI 文件,我还可以在我的应用程序中显示我的 SwiftUI 视图。但是,如果我尝试在我的 SwiftUI 文件的 XCode 内进行预览,我会收到以下错误:
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”有关" 和其他线程问题,如果我搜索相同的错误,我将重定向这些问题。例如,其中一个帖子是这样的:
但我不使用诸如“持久性容器”之类的复杂事物。我只在我的 userDefaults 中使用一些键,这些键被保存在那里并被检索。我也使用 Firebase。老实说,我对线程和并发了解不多。 那么有人可以向我解释为什么会出现这个错误以及为什么我会出现这样的奇怪行为吗?为什么我的简单图像和矢量资源会出现这样的问题????
我问过我的一位同事,她也从事同一个项目,如果她尝试打开新创建的 SwiftUI 视图的预览,她会得到相同的结果。
当我第一次阅读这个问题时,我没有意识到这是一个 编译器 错误——我以为它是在应用 运行 时发生的。
当编译器出现这样的错误时,表明发生了崩溃,这是编译器中的错误。总是。那永远不应该发生。从您的评论看来,您的 JSON 文件似乎触发了此错误。我不知道 JSON 文件是否有些奇怪,或者 Xcode 不喜欢在资产目录中包含 JSON。不管怎样,这是一个 Xcode 错误,因为在最坏的情况下 Xcode 应该告诉你不要把 JSON 文件放在那里而不是这样做。
很高兴听到您找到了解决方法。这不是您可以实际修复的问题,但如果您的变通方法满足您的需要,那么就足够了。 Apple 可以修复它,所以我建议访问 https://feedbackassistant.apple.com 并提交有关此问题的错误。