I create a URL bookmark with `URL.bookmarkData(options: [], includingResourceValuesForKeys: [.localizedNameKey])` and resolve it with `NSURL(resolvingBookmarkData: bookmarkData, options: [], relativeTo: nil, bookmarkDataIsStale: nil) as URL`. This works fine within my main app, but when sharing the bookmarkData via an App Group with my Share Extension, it gives the error "The file couldn't be opened because you don't have permission to view it.". Is there any way I can do this?
Hi Nickkk! This is presumably failing because the app you shared to doesn't have access to the original app's sandbox. You can resolve this by specifying .withSecurityScope in your option set when creating the bookmark. The target application will be able to resolve the bookmark, and must call startAccessingSecurityScopedResource() and stopAccessingSecurityScopedResource() when it needs to access the resource to which the bookmark refers. For more information, see:
https://developer.apple.com/documentation/foundation/nsurl/bookmarkcreationoptions/1413824-withsecurityscope
https://developer.apple.com/documentation/foundation/nsurl/1417051-startaccessingsecurityscopedreso
https://developer.apple.com/documentation/foundation/nsurl/1413736-stopaccessingsecurityscopedresou
https://developer.apple.com/documentation/foundation/nsurl/bookmarkcreationoptions/1413824-withsecurityscope
https://developer.apple.com/documentation/foundation/nsurl/1417051-startaccessingsecurityscopedreso
https://developer.apple.com/documentation/foundation/nsurl/1413736-stopaccessingsecurityscopedresou