How to declare association with hidden / dot files from the Info.plist?

First post on the Apple Dev forum, so not sure to be at the right place..

Original question was on StackOverFlow (http://stackoverflow.com/questions/38458237/how-to-declare-association-with-hidden-dot-files-from-the-info-plist) but as no answer I take my chance here.


I'm trying to associate some Eclipse specific project files with my application:

  • .project
  • .cproject


Hence I've put both extensions declaration into the application's Info.plist :


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    ...
    <key>CFBundleDocumentTypes</key>
    <array>
        <dict>
            <key>CFBundleTypeIconFiles</key>
                    <string>MyAPP.icns</string>
            <key>CFBundleTypeName</key>
                <string>My App Files</string>
            <key>CFBundleTypeRole</key>
                <string>Viewer</string>
            <key>LSHandlerRank</key>
                <string>Owner</string>
            <key>LSItemContentTypes</key>
                <array>
                    <string>my.app.ext.project</string>
                    <string>my.app.ext.cproject</string>
                </array>
        </dict>
    </array>
    <key>UTExportedTypeDeclarations</key>
    <array>
        <dict>
            <key>UTTypeConformsTo</key>
                <array>
                        <string>public.data</string>
                </array>
            <key>UTTypeDescription</key>
                <string>Eclipse Project file</string>
            <key>UTTypeIdentifier</key>
                <string>my.app.ext.project</string>
            <key>UTTypeTagSpecification</key>
            <dict>
                    <key>public.filename-extension</key>
                        <string>project</string>
                    <key>public.mime-type</key>
                        <string>text/plain</string>
            </dict>
        </dict>
        <dict>
            <key>UTTypeConformsTo</key>
                <array>
                        <string>public.data</string>
                </array>
            <key>UTTypeDescription</key>
                <string>Eclipse C-Project file</string>
            <key>UTTypeIdentifier</key>
                <string>my.app.ext.cproject</string>
            <key>UTTypeTagSpecification</key>
            <dict>
                    <key>public.filename-extension</key>
                        <string>cproject</string>
                    <key>public.mime-type</key>
                        <string>text/plain</string>
            </dict>
        </dict>
    </array>
</dict>
</plist>


However this solution works well with XXX.cproject and YYY.project files, but no way with Eclipse files I have to manage. Sounds like OSX, unlike Linux and Windows, doesn't allow association with hidden files.


As my supported file formats are static, is there a possibility to declare association by filename instead of extensions?

By reading types in https://developer.apple.com/library/ios/documentation/Miscellaneous/Reference/UTIRef/Articles/System-DeclaredUniformTypeIdentifiers.html#//apple_ref/doc/uid/TP40009259 I guess that this isn't possible...


Anyway I can't believe that there is no technical approach to associate app with hidden files. So of course any other solutions are welcomed :-)


Hereafter a link to download small snippet app that highlight my problem :

https://db.tt/2eb8YCNc

The issue is not that those files are hidden, it's that they don't have file name extensions and thus there's no way for the system to determine their type. A dot at the beginning of a file name does not introduce an extension; it's just part of the name.


In other words, I expect you could make an app handle .foo files and it would work just fine for .project.foo, even though that would be a hidden file.


Unfortunately, Eclipse seems to have standardized on file names without extensions and you're out of luck. You can check if the system knows something about the file type of .project by examining the output of "mdls .project".

Thanks @KenThomases for your reply, indeed that confirm my thoughts that there is no way by using the extension method.

Eclipse specs are as they are and this part can't be overrided, an Eclipse project is recognized with this description file:

"This file is always called ".project", and is located as a direct member of the project's content area." (http://help.eclipse.org/neon/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fmisc%2Fproject_description_file.html)


Here is the output of mdls on .project files:

kMDItemFSContentChangeDate = 2016-07-20 07:36:41 +0000
kMDItemFSCreationDate      = 2016-07-20 07:36:41 +0000
kMDItemFSCreatorCode       = ""
kMDItemFSFinderFlags       = 0
kMDItemFSHasCustomIcon     = 0
kMDItemFSInvisible         = 1
kMDItemFSIsExtensionHidden = 0
kMDItemFSIsStationery      = 0
kMDItemFSLabel             = 0
kMDItemFSName              = ".project"
kMDItemFSNodeCount         = 647
kMDItemFSOwnerGroupID      = 20
kMDItemFSOwnerUserID       = 508
kMDItemFSSize              = 647
kMDItemFSTypeCode          = ""


AFAIU in this case os x only rely on the mime-type (application/xml; charset=us-ascii) to find any associated application.


I've seen from Finder that association can be set dinstinctly on a given file, without impacting the whole system configuration.

In this case I suppose that association is stored into the file metadata, how can I perform this operation by a programatic approach (script or anything else) ?

How to declare association with hidden / dot files from the Info.plist?
 
 
Q