Custom UTIs based on com.apple.package don't always work


Steve Mills
 

I have a file type all set up in my target's Document Types and Exported UTIs as so:

<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>livery</string>
</array>
<key>CFBundleTypeName</key>
<string>Livery</string>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>LSItemContentTypes</key>
<array>
<string>$(PRODUCT_BUNDLE_IDENTIFIER).livery</string>
</array>
<key>LSTypeIsPackage</key>
<integer>1</integer>
</dict>
</array>

<key>UTExportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>com.apple.package</string>
</array>
<key>UTTypeDescription</key>
<string>Livery</string>
<key>UTTypeIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER).livery</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>livery</string>
</array>
</dict>
</dict>
</array>

It always work on the Macs where I've done most of the development work, which started on 10.10 and is now 10.13. When I sync and run it on mac 10.14 Mac, the files never work because [url getResourceValue:&type forKey:NSURLTypeIdentifierKey error:nil] says it's a public.folder instead of my declared UTI. I can make it work by copying the app into /Applications and running it from there. From then it will work when running from Xcode. But as soon as I delete the app from /Applictions and then run from Xcode again, it goes back to thinking it's public.folder.

Why doesn't this work like it should? And by that I mean that if one is developing an app that has custom UTIs, they should *work* during development. I could just leave a copy in /Applications, but I shouldn't have to.

--
Steve Mills
Drummer, Mac geek


Quincey Morris
 

On Mar 13, 2019, at 21:17 , Steve Mills via Groups.Io <sjmills@...> wrote:

<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>livery</string>
</array>
<key>CFBundleTypeName</key>
<string>Livery</string>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>LSItemContentTypes</key>
<array>
<string>$(PRODUCT_BUNDLE_IDENTIFIER).livery</string>
</array>
<key>LSTypeIsPackage</key>
<integer>1</integer>
</dict>
</array>

Well, this is kind of wrong. CFBundleTypeExtensions and LSTypeIsPackage should not be specified in the document type when you’re using an exported UTI. I don’t really recall their presence actively messing things up, but I suggest you get rid of them. AFAICT, the most complete and accurate documentation is this:


and you have to read Table 2 carefully to see what doesn’t apply any more (i.e. since 10.5!).

When I sync and run it on mac 10.14 Mac …

What does “sync” mean in this context? Is Xcode running on the 10.14 Mac, or is it running on a 10.13 Mac? Are you doing some kind of command line copy to move the bundle between Macs?


Steve Mills
 

On Mar 14, 2019, at 01:03:16, Quincey Morris <quinceymorris@rivergatesoftware.com> wrote:

Well, this is kind of wrong. CFBundleTypeExtensions and LSTypeIsPackage should not be specified in the document type when you’re using an exported UTI.
Where is it documented that it's wrong? I don't think it's actually wrong. iMovie, for example, has com.apple.iMovieEvent declared both as an exported UTI and as a document type. Besides, it *does* work when the app is in /Applications.

I don’t really recall their presence actively messing things up, but I suggest you get rid of them. AFAICT, the most complete and accurate documentation is this:

https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html#//apple_ref/doc/uid/TP40009249-101685-TPXREF107

and you have to read Table 2 carefully to see what doesn’t apply any more (i.e. since 10.5!).
Yes, deprecated keys don't actually mess things up though when newer ones take precedence.

When I sync and run it on mac 10.14 Mac …
What does “sync” mean in this context? Is Xcode running on the 10.14 Mac, or is it running on a 10.13 Mac? Are you doing some kind of command line copy to move the bundle between Macs?
Sync my source from the repo. Some might only know the phrase "pull my changes from the server" if they haven't used SCMs other than svn or git. Having cut my teeth on Perforce and used it for the first 15 years of my career, I'll probably never stop using the term "sync" for this.

--
Steve Mills
Drummer, Mac geek