Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


Chad Goodyear
Chad Goodyear
9,634 Points

I want to import ('open in' menu) a .zip file to an iOS app. I have the .zip Document Type - where do I go from there?

I have a Swift 5 iOS project. If you get emailed a .zip attachment and open it with your iPhone mail app you can use the OpenIn icon and see my app as I have added the com.pkware.zip-archive Document Type.

I have ZIPFoundation installed with Carthage to unzip the file.

But how to I 'get' the file or a reference to a URL or Object. I guess so code in appdelegate is watching for it some how - but I don't even know how to refer to this process to google it.

Any thoughts? Many thanks

1 Answer

Chad Goodyear
Chad Goodyear
9,634 Points

Found a tutorial at https://www.raywenderlich.com/5244-document-based-apps-tutorial-getting-started

which included what I need (I think):

func application(_ app: UIApplication, open inputURL: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {

// 1 guard inputURL.isFileURL else { return false }

// 2 guard let rootController = window?.rootViewController as? RootViewController else { return false }

// 3 rootController.openRemoteDocument(inputURL, importIfNeeded: true) //my version of this goes here. return true }