Make your app's files user-visible on the iPhone

Make your app's files user-visible on the iPhone

Β·

1 min read

In this blog post, I will show how you can ensure the user can access your app's files in the Documents directory through other services like Spotlight or the Files app.

Store local files in the Documents directory of your app's container when you intend to make those files user-visible.

try? "Hello, world!".write(to: URL.documentsDirectory.appending(path: "Demo.txt"), atomically: true, encoding: .utf8)

Per default, files in your app's Documents directory will not be accessible in the iPhone's Files app.

No Files

Your app needs to support "Open in Place" and indicates that file sharing is enabled, both configured in your Info.plist file by adding the following property list keys:

Info.plist screenshots with UIFileSharingEnabled and LSSupportsOpeningDocumentsInPlace

    <key>UIFileSharingEnabled</key>
    <true/>
    <key>LSSupportsOpeningDocumentsInPlace</key>
    <true/>

Files app can show them now in the "On My iPhone" or "On My iPad" location.

Folder shown in Files App

File shown in Files App

People can also find their files in Spotlight and on iPad, drag and drop them to other apps.

A summary on YouTube is available: