Hello im getting an error if i implement SwiftUI into my app which is based on storyboard at the moment. I made a SwiftUI file and i can also display my SwiftUI view within my app. However if i try to make a preview within XCode of my SwiftUI file i get the following error:
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
The thing is i dont know why i get this error. If i run my app on the simulator i dont see any error like this. This error does NOT occur in the simulator, humh?
The above code occurs within the step "Showing All Messages CompileAssetCatalog" in the log. Because the error has been occurred in this step i thought it could have some relation to the assets (images and vectors graphics) which i am using. I therefore deleted my whole asset files except my "AppIcon" and tried to run the preview within XCode again and it did work!!. However i dont know why my assets has to do with "NSObjectManager" or "PersistentContainer" "CoreData" and other Thread problems where im redirected if i search for the same error. One of the posts is for example this: FetchedResultsController Swift 3 API Misuse: Attempt to serialize store access on non-owning coordinator
But i dont use complex things like "Persistent Container". I only use some keys in my userDefaults which are being saved there and also being retrieved. I also use Firebase. I dont understand much about threads and concurrency to be honest. So can someone explain me why exactly this error occurs and why i get really strange behaviour like this? Why do my simple image and vector assets cause problems like this????
I asked one of my colleagues who is also working on same project she gets the same result if she tries to open the preview of a new created SwiftUI view.