Cannot open file from iOS Files app via the Open In <My App> share sheet: no file at the provided file URL exists
I fixed this by adjusting some settings in the app's Info.plist.
I switched UISupportsDocumentBrowser
to false
, and added LSSupportsOpeningDocumentsInPlace
, also set to false
.
I think these settings were set incorrectly (by me) after I received an email from App Store Connect stating:
Invalid Document Configuration - Document Based Apps should support either the Document Browser (UISupportsDocumentBrowser = YES) or implement Open In Place (LSSupportsOpeningDocumentsInPlace = YES/NO). Visit https://developer.apple.com/document-based-apps/ for more information.
Setting the LSSupportsOpeningDocumentsInPlace
flag to false prevents the app to be automatically opened when selecting the file in the Files App. In case the the file is opened in place one needs to request/unlock access first:
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool { let opensInPlace = options[.openInPlace] != nil opensInPlace ? url.startAccessingSecurityScopedResource() : nil let fileExists = FileManager.default.fileExists(atPath: url.path) opensInPlace ? url.stopAccessingSecurityScopedResource() : nil }
I don't think you can share files between different apps (that are not in the same app group):