How do I associate a custom file type with a Catalyst app?

I'm trying to associate a custom file type and extension with my Mac Catalyst app.

On the Mac, I can get this to work by adding the following key/values to my Info.plist:

Code Block
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeName</key>
<string>CustomUTI</string>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>LSHandlerRank</key>
<string>Owner</string>
<key>LSItemContentTypes</key>
<array>
<string>com.jnpdx.customuti</string>
</array>
</dict>
</array>


Code Block
<key>UTExportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.data</string>
</array>
<key>UTTypeDescription</key>
<string>CustomUTI</string>
<key>UTTypeIcons</key>
<dict/>
<key>UTTypeIdentifier</key>
<string>com.jnpdx.customuti</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>customuti</string>
</array>
<key>public.mime-type</key>
<array>
<string>custom/uti</string>
</array>
</dict>
</dict>
</array>


Once I've modified the Info.plist, sometimes I have to build my app in Xcode and then drag the product to the Applications directory before launchd will associate the file type correctly.

Once I do this, my app appears in the "Open with..." menu.
However, the steps do not appear to work for a Catalyst target. If you look at the Twitter thread that I linked to before, it suggested that the Applications folder trick worked at one point, but I have had no luck getting it to work in Big Sur (I'm running 11.2.3).

I've created a sample repo (including a couple of sample files) that you can try this out with so a tester can avoid the process of creating the targets. There is nothing here except for a "Hello, world!" app with the Info.plist set up as described above, with a macOS native target and a Catalyst target. (Remember the hint about dragging to Applications): https://github.com/jnpdx/MacNativeUTITest

Replies

To get an “Open with...” item in Catalyst apps, you must set LSSupportsOpeningDocumentsInPlace to true in your Info.plist.