Search code examples
iosswiftfile-extensioninfo-plist

Swift - Importing Custom File


I am trying to import and open a custom file in my app using the tutorial below

https://chariotsolutions.com/blog/post/importing-data-via-custom-file-types-in/

This is how my info plist looks like enter image description here

When I drag the file with the extension ".AMarkUp", the app just crashes

2019-03-11 11:28:37.661461+1100 Project[15404:836338] * Assertion failure in -[UIApplication _applicationOpenURLAction:payload:origin:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKitCore_Sim/UIKit-3698.93.8/UIApplication.m:6851 2019-03-11 11:28:37.682291+1100 Project[15404:836338] * Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Application has LSSupportsOpeningDocumentsInPlace key, but doesn't implement application:openURL:options: on delegate '

How can I fix this issue doesn't "implement application:openURL:options: on delegate"?

Thanks for the help


Solution

  • You need to implement the specified UIApplicationDelegate method in your AppDelegate.swift file.

    func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any]) -> Bool {
        // handle the file here
    
        return true // or false based on whether you were successful or not
    }