I have an iOS app that stores images in Core Data using External Storage. From time to time I get crash reports with the following error (in this particular instance it's running on a M1 Mac via Catalyst):
Unable to open file with path /Users/user/Library/Group Containers/group.myapp/.myapp_SUPPORT/_EXTERNAL_DATA/61681DBF-B1A4-4325-9104-E21A1218F046 (92)
The relevant stack trace bit looks like this:
0 CoreFoundation +0xfc408 __exceptionPreprocess 1 libobjc.A.dylib +0x1aea4 objc_exception_throw 2 CoreData +0x12cda0 +[_PFRoutines readExternalReferenceDataFromFile:] 3 CoreData +0xe9db8 -[_PFExternalReferenceData _attemptToMapData:] 4 CoreData +0xd7894 -[_PFExternalReferenceData _retrieveExternalData] 5 Foundation +0x46f2f8 specialized static Data._unconditionallyBridgeFromObjectiveC(_:) 6 MyApp +0x15eb80 Image.thumbnailImage.getter (Image.swift:25:22)
All I'm doing in Image.swift:25:22
is declaring a variable with the contents of the image:
let data = self.thumbnail // 'thumbnail' is my Binary Data attribute
I've tried to reproduce this crash on my machine by intentionally deleting, corrupting and changing permissions on external storage files but that doesn't work.
Does anyone have the slightest idea of what's going on, or how to prevent or fix this?