Apply document icon from Xcode or my code or...

A search reveals a reference or two to this problem but I can’t find any solutions so…

How can I assign a .icns icon to a document that my app creates? I’m able to apply a custom icon to my app (with the CFBundleIconFile key), and I’m able to double-click on the documents I create and open them up in my app (with the CFBundleTypeExtensions key). However, I’d like the user to see a document with my icon and say, “Aha, if I double-click this it will open up in that marvelous application that eliminates the national debt and brings world peace and . . .”

Thanks for any advice…

  • Dan

Hi,

My suggestion is for you to go over the programming tutorial in the AppleScript Studio Programming Guide under Xcode.

It will show you how to create the custom icon for AppleScript Studio applications using tools such as the Icon Composer and other related utility utilities that are bundled with Xcode.

Good luck!

archseed :slight_smile:

Thanks archseed, I’ll do that. As I said I can set the application’s icon, it’s the document’s I’m confused about, but admittedly I haven’t checked the programming guide so I’ll do that.

Thanks for responding…

  • Dan

hi dan,

sorry. i must admit. i missed out totally on what your problem was. i thought all along that you were referring to the application icon. i was too hasty, shucks!

am not familiar with customizing the document icon and/or making the AS Studio application generate a custom icon. i do sincerely hope that you will find tips and help from the Xcode bundled documentations and from the programming tutorial.

good luck!

archseed :slight_smile:

Hi,

I’m quite sure the document files had customa icons once, but I can’t remember how I did it. Maybe I didn’t use an icns file and maybe the document types didn’t have file type or creator.

gl,

Thanks guys - if I figure it out I’ll post it. :cool:

  • Dan

Although (a further thought) it’s curious that if I take a plain old text file and change its extension to “.xls” it suddenly assumes an Excel icon - no intervention there from anyone but Finder, presumably, so I wonder if it’s even worth digging into Xcode for this. Oh well, learning is a daily routine (can’t remember where I heard that :))

There must be something deeper that takes priority over that which we have known.

kel,

that’s real nice to say.

if that’s your original, philosophical expression it’s very cool!

i will keep it in my collection.

archseed :slight_smile:

Hi archseed,

I did it again. Under document types, I gave it my own extension zzz. After the rebuild, a saved document had the document icon.

gl,

Hi dant,

One thing I’ve noticed is that you need to give the document a creator type also. I didn’t realize that you the original poster wasn’t archseed to whom I had suggested to use a creator type to have a user Open the document in the app. See my other post on how to set the creator type of the saved file. Mainly, you just set the creator type with the Finder

tell app “Finder”
set creator type of (applescriptreferencetothefile) to (myapplicationcreatortype)
end tell

If you have any questions, please ask.

Edited: and btw, this is for only the creator type. You set your own extension in the targets pane for document types. You set the OS types for file types like “TEXT”

The hard part about this is that you’re in limbo. Not knowing which way Apple will turn, until they make the turn. They need to get their head out of their you no what.

gl,

Thank you kel. The first thing I had done was to change the creator type about a week or two ago but it didn’t work so I figured, well, OS9 days are gone. Apparently, though, I’d done something wrong, or else it has to be in conjunction with the target change as well which I hadn’t come up with yet.

In any event, I look forward to trying this at the first opportunity in a busy day today, hopefully this morning. Thanks very much for your and archseed’s efforts!

  • Dan