I have defined a custom document type containing binary data for my app, with identifier "com.mycompany.gcp", using an Exported UTI. I am using this document type to exchange data with macOS and iOS versions of my app. After much trial and error, it is working reasonably well. However, I feel like I am missing a critical step.
When I export a file from my app, I create the file using FileManager.createFile(atPath:, contents:, attributes:)
. I create the file with my gcp extension, however I do not know how to specify the identifier type, specifically to set it to "com.mycompany.gcp". When I export the file, if I inspect it with mdls, kMDItemContentType = "dyn.ah62d4rv4ge80s25u", which I assume refers to a dynamic identifier, rather than my identifier.
My questions are: 1) is there a way to set the identifier when creating the file? I have tried the NSURL methods to set the identifier without success. 2) does this matter?
I feel like the answer the question 2 is yes. With iOS, if I email or airdrop the file, I can open it with my app. However, with iMessage, no action occurs when I tap on a sent file.
Here are the relevant keys from the Info.plist for the iOS version of my app:
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeIconFiles</key>
<array/>
<key>CFBundleTypeName</key>
<string>GCP File</string>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>LSHandlerRank</key>
<string>Owner</string>
<key>LSItemContentTypes</key>
<array>
<string>com.mycompany.gcp</string>
</array>
</dict>
</array>
<key>UTExportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.data</string>
</array>
<key>UTTypeDescription</key>
<string>GCP File</string>
<key>UTTypeIdentifier</key>
<string>com.mycompany.gcp</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>gcp</string>
</array>
</dict>
</dict>
</array>