I am trying to use file packages for an iOS app be defining an UTI type. After googling and looking at the entries in Xcode.plist, I tried a few things but kept running into problems. My app creates a few test documents and then tries to read those files with my custom UTI.
If I don't specify "LSItemContentTypes", then finder correctly sees them as packages. But then mdls returns "dyn.longstring" as kMDItemContentType.
If I do specify "LSItemContentTypes", then the kMDItemContentType is correct. But finder sees it as a folder.
In both cases the UTI I get via
[url getResourceValue:&UTI
forKey:NSURLTypeIdentifierKey
error:nil];
is incorrect. It either returns "dyn.longstring" or "public.folder". My app doesn't load these files because of the incorrect UTI. I could rewrite this but want to do it the right way with UTI's.
I defined an iOS file package as document type and exported UTI type as can be seen below. What am I overlooking?
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>tdp</string>
</array>
<key>CFBundleTypeName</key>
<string>MyFilePackage</string>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>LSItemContentTypes</key>
<array>
<string>reverse.dns.ios.package</string>
</array>
<key>CFBundleTypeIconFile</key>
<string>Default</string>
<key>LSIsAppleDefaultForType</key>
<true/>
<key>LSTypeIsPackage</key>
<true/>
</dict>
</array>
</plist>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename.extension</key>
<array>
<string>tdp</string>
</array>
</dict>
<key>UTTypeIdentifier</key>
<string>reverse.dns.ios.package</string>
<key>UTTypeConformsTo</key>
<array>
<string>com.apple.package</string>
<string>public.composite-content</string>
</array>
</dict>
</array>
</plist>
Was having a similar issue, including the UTI showing up as "dyn.longstring". Seems like the fix was to remove CFBundleTypeExtensions attribute (which is deprecated). This combination in the info.plist worked for me:
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeName</key>
<string>My App Name</string>
<key>LSHandlerRank</key>
<string>Owner</string>
<key>LSItemContentTypes</key>
<array>
<string>my.content.type</string>
</array>
<key>LSTypeIsPackage</key>
<true/>
</dict>
</array>
<key>UTExportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>com.apple.package</string>
<string>public.composite-content</string>
</array>
<key>UTTypeDescription</key>
<string>My App Name</string>
<key>UTTypeIdentifier</key>
<string>my.content.type</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<string>myextension</string>
</dict>
</dict>
</array>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With