[R-SIG-Mac] UTIs for files handled by R?

Kevin Ushey kev|nu@hey @end|ng |rom gm@||@com
Thu Nov 10 18:16:51 CET 2022


On my macOS machine, files with the .R extension are seen as "Rez" source files:

$ touch hello.R && mdls -name kMDItemContentType hello.R
kMDItemContentType = "com.apple.rez-source"

I believe this is because Xcode comes with an Info.plist file that
declares and registers this file type; e.g. it has entries like (from
XML)

<dict>
<key>CFBundleTypeName</key>
<string>Rez Source</string>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>LSIsAppleDefaultForType</key>
<true/>
<key>LSItemContentTypes</key>
<array>
<string>com.apple.rez-source</string>
</array>
</dict>

<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.source-code</string>
</array>
<key>UTTypeDescription</key>
<string>Rez Source</string>
<key>UTTypeIcons</key>
<dict>
<key>UTTypeIconBackgroundName</key>
<string>rez-fill</string>
</dict>
<key>UTTypeIdentifier</key>
<string>com.apple.rez-source</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>r</string>
</array>
</dict>
</dict>

It looks like R.app also declares document types for R source files,
but it doesn't assign a UTI, and macOS doesn't seem to "prefer" the
definition provided by R.app.

Could the R.app application also register file types in a similar way,
and perhaps in a way that tells macOS to prefer the definitions in
R.app to those in Xcode? (I'm not an expert, but LSHandlerRank should
be a way of declaring R.app as a higher-priority definition provider
for files with the .R extension, as per
https://developer.apple.com/documentation/bundleresources/information_property_list/cfbundledocumenttypes/lshandlerrank)

Thanks,
Kevin



More information about the R-SIG-Mac mailing list