Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS 12 Xcode 10 application:openURL:options: Crash

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..

like image 947
martin010 Avatar asked Sep 26 '18 11:09

martin010


1 Answers

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

like image 183
Radu Ursache Avatar answered Oct 19 '22 23:10

Radu Ursache