[Openmcl-devel] Creating extensions associations for my application
plkrueger at comcast.net
Wed Jan 12 18:48:54 PST 2011
On Jan 12, 2011, at 4:46 PM, Michael Minerva wrote:
> I would like to create file extension associations for my application and I am having trouble figuring out how to do this with build build-application. It seems that the cocoa way to do this would be to add a CFBundleDocumentTypes key to the info.plist of my application. When I tried to do this using build-application the first thing I noticed is that make-info-dict (which seems to be the standard way to create a plist by way of of build-application's info-plist key) does not accept a key for CFBundleDocumentTypes key, also it seems that there is no way to specify an actual info.plist file for build-application to use, instead it seems that you must specify an NSDictionary to be used to create the plist from (am I mistaken)? If all of this is correct, how would one specify file extension associations and icons to use with those files through ccl? Thanks a lot.
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
I'm writing to offer some help if you have specific questions. You may have seen my recent email about my "new tools" contrib code that will hopefully get checked in soon. It replaces build-application with something more comprehensive that lets you define and build applications that you can run either under the IDE or as stand-alone applications. Build-application was just missing too much of what I wanted to be able to do to build my own applications.
I'm going to assume that you're not very experienced with Cocoa applications and Info.plists; if that's not the case I'll apologize in advance for saying things you might already know. If you haven't already seen it, you might want to get Apple's document titled: "Information Property List Key Reference". That is a fairly comprehensive look at the sorts of things that go into Info.plists.
In the process of my work I've learned quite a bit about Info.plist contents and in fact I'm still trying to work out some little problems that show up in more complex situations. It's surprising how touchy that all can be. If you are creating an application that has just your own document and doesn't also incorporate all of the IDE document types it isn't too bad.
Be aware that there are two different ways to specify document types in Info.plists. The older model (which still works) is what is used for the CCL IDE. So assuming that you have the IDE built, you can look at the Info.plist for it (ask me if you don't know how to get to it in the finder). Assuming that you have Apple developer tools installed (which you need to rebuild CCL, so I'm assuming you have them), you just double-click on an Info.plist to open it in the application "Property List Editor". That's the best way to see what is inside one and even to edit one for your own application if you want. You can do this even after you use build-application to create a bundle to modify it however you want. If you use the CCL Info.plist as a model for what you want to do you should be ok. Parenthetically, if you rename the Info.plist prototype file that you were pointed to by Matthew Emerson so that it is just named Info.plist, then you can double-click on it to open it up the same way. IMHO, that's a lot easier than trying to parse through all the XML in that file.
That old model was deprecated in 10.4. The new model may be better in some ways, but it also seems a little bit touchier to me. You can see the new model by looking at the Info.plists for other existing Apple applications that use it. TextEdit is one, as is InterfaceBuilder. Looking at the Info.plists for either of those can be educational.
You can also include keys that support both the old and new model and keys for the old model will be ignored. It appears, however, that if you only have the new model defined for some documents and not others that things get confused at runtime. I'm not sure I totally understand all that yet, which is one of the things that has delayed checkin of my code. I've had to create a new prototype Info.plist for the CCL IDE using the new model. I need that for those cases where I want to create a stand-alone application that incorporates both my own document (with Info.plist entries in the new format) and CCL's documents (which therefore must also have Info.plist entries in the new format). There are also a couple of order dependencies that you need to be aware of, but again, only if you are defining multiple document types. Ask me if you have multiple documents. In retrospect it might have saved me a lot of time to just stay with the old model, but that's life.
If you get confused, email me. I've been working on my application builder tools for about a year, so I'm well down the path that I suspect you are just starting. Hopefully I can get my code checked in fairly soon and that may save you some grief too.
More information about the Openmcl-devel