How does OSX tell what app to open when you double click a file?

Paul Dupuis paul at researchware.com
Thu Aug 8 07:34:28 EDT 2019


On 8/6/2019 10:10 PM, Mark Waddingham via use-livecode wrote:
> On 2019-08-06 23:59, Paul Dupuis via use-livecode wrote:
>> For example, if you drag installed 5 apps, APP1, 2, 3, etc, that all
>> had a info.plist defintion for a .xyz file extension onto a virgin OSX
>> system out of the box and then double-clicked a .wyz file, which of
>> the 5 would open?
>
> I *think* the answer to this question probably lies here:
>
> https://developer.apple.com/library/archive/documentation/Carbon/Conceptual/LaunchServicesConcepts/LSCConcepts/LSCConcepts.html#//apple_ref/doc/uid/TP30000999-CH202-TP9 
>
>
> The sections on 'Application Registration' and 'Preferred 
> Applications' are probably the most pertinent - although it isn't 
> entirely clear how the two mechanisms co-exist: registration suggests 
> the 'most recent' modification time wise app is stored against a file 
> kind, but preferred applications suggests that multiple apps are 
> stored but the newest CFBundleVersion wise is chosen.
>
> Warmest Regards,
>
> Mark.
>

Thank you again!

This section of that web page was exactly what I was looking for:


      Preferred Application for a Document

For individual document files (whether specified by a file-system 
reference or a URL with scheme |file|), the criteria are as follows:

 1.

    If the user has specified an explicit binding for the document (or
    for the entire document type to which it belongs), the preferred
    application is the one the user has specified.

 2.

    If the document has a filename extension (or if one has been
    specified as a parameter to |LSGetApplicationForInfo|), find all
    applications in the Launch Services database that claim to accept
    documents with that extension.

 3.

    If the document carries a four-character file type (or if one has
    been specified as a parameter), find all applications that claim to
    accept files of that type.

 4.

    If more than one application has been found as a result of steps
    2–3, apply the following criteria in the order shown:

     1.

        If the document carries a four-character creator signature (or
        if one has been specified as a parameter), give preference to
        any application that claims to accept documents with that
        signature (typically the application to which the signature
        belongs).

     2.

        Give preference to native OS X applications over those that run
        in the Classic emulation environment.

     3.

        Give preference to applications residing on the boot volume over
        those residing on other file-system volumes.

     4.

        Give preference to applications residing on a local volume over
        those residing on a remote volume.

     5.

        If two or more versions of the same application have been found,
        give preference to the one with the latest version number as
        identified by |CFBundleVersion
        <https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html#//apple_ref/doc/plist/info/CFBundleVersion>|.

If two or more candidate applications remain after all of the foregoing 
criteria have been applied, Launch Services chooses one of the remaining 
applications in an unspecified manner.





More information about the Use-livecode mailing list