iOS 12 Xcode 10 application:openURL:options: Crash
Asked Answered
A

1

5

I recently noticed some issues with my app causing a Warning when uploading to the Appstore:

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.

My app responds to a custom extension set in its plist 'Document Types' and worked fine up until iOS 12/Xcode 10.

When adding 'Supports opening documents in place' to YES in the .plist and 'Supports Document Browser' to NO it crashes with this message:

'Application has LSSupportsOpeningDocumentsInPlace key, but doesn't implement application:openURL:options: on delegate'

My app supports iOS 8 and higher, and worked fine responding to:

(BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation

in my AppDelegate.

When I add the new

- (void)openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenExternalURLOptionsKey, id> *)options completionHandler:(void (^)(BOOL success))completion 

it still crashes with the error above..

Awaken answered 26/9, 2018 at 11:22 Comment(3)
Did you implement - (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options; as stated bu the crash error message? That's not the one you implemented.Kilderkin
Let me check this..Awaken
Jep, my bad.. this works, however it created a new issue... When tapping the file from iCloud drive it now gives me an 257 (access denied) error.. Where as in previous iOS (<12.0) it worked fine.Awaken
B
16

add this in your app delegate:

- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options {
    return YES;
}

since ios 12 it is required if you also added LSSupportsOpeningDocumentsInPlace in your info.plist

Bewray answered 30/1, 2019 at 12:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.