Opening package with LiveCode on OSX

David Bovill david at vaudevillecourt.tv
Tue Mar 15 06:40:09 EDT 2011


Thanks Terry. Doing some research:

   - Document Packages<http://developer.apple.com/library/mac/#documentation/CoreFoundation/Conceptual/CFBundles/DocumentPackages/DocumentPackages.html#//apple_ref/doc/uid/10000123i-CH106-SW1>
   - All about Bundles<http://www.mactipsandtricks.com/articles/Wiley_HT_appBundles2.lasso>

It seems that all that is needed is, as you say, to add some entries to the
plist of the app:

> To register a document as a package, you must modify the document type
> information in your application’s information property list (Info.plist)
> file. The *CFBundleDocumentTypes*<http://developer.apple.com/library/mac/#documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html#//apple_ref/doc/uid/20001431-101685>key stores information about the document types your application supports.
> For each document package type, include the *LSTypeIsPackage* key with an
> appropriate value. The presence of this key tells the Finder and Launch
> Services to treat directories with the given file extension as a package.
> For more information about Info.plist keys, see *Information Property List
> Key Reference<http://developer.apple.com/library/mac/documentation/General/Reference/InfoPlistKeyReference/Introduction/Introduction.html#//apple_ref/doc/uid/TP40009247>
> *.
>
> Document packages should always have an extension to identify them—even
> though that extension may be hidden by the user. The extension allows the
> Finder to identify your document directory and treat it as a package. You
> should never associate a document package with a MIME type or 4-byte OS
> type.
>
Now finding out exactly what you need to do to the plist is a bit more
tricky:

*LSTypeIsPackage*

"Document is a package or bundle”

Boolean

Specifies whether the document is distributed as a bundle. If set to true,
the bundle directory is treated as a file. (In Mac OS X v10.4 and later,
this key is ignored if the LSItemContentTypes key is present.)

And then you need to do stuff with the more complicated *
CFBundleDocumentTypes<http://developer.apple.com/library/mac/#documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html#//apple_ref/doc/uid/20001431-101685>
*

   - Information Property List Key
Reference<http://developer.apple.com/library/mac/#documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html#//apple_ref/doc/uid/TP40009249-SW1>


To edit a plist in LiveCode, you can use
plistbuddy<http://developer.apple.com/library/mac/#DOCUMENTATION/Darwin/Reference/ManPages/man8/PlistBuddy.8.html>on
OSX recent OSX systems (post 10.5).

It seems for OSX systems earlier than 10.5, you need to use the command line
utility plutil<http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man1/plutil.1.html>to
convert from binary to XML and back again. Then you can use LiveCodes
XML
function to edit the XML.

   - plutil <http://hints.macworld.com/article.php?story=20050430105126392>
   - plistbuddy<http://developer.apple.com/library/mac/#DOCUMENTATION/Darwin/Reference/ManPages/man8/PlistBuddy.8.html>

So all we now need is a little recipe to script plistbuddy to add the right
keys.



More information about the Use-livecode mailing list