Hi - Bit of an odd one, not had to look at this before. Is it possible to define the app icon in code?
You can do this with a build script.
On OS X ? Use DockItem.
Thanks - it’s OS X and Win.
I’m trying to do something like xCode does for it’s betas which would be quite useful for our build process
[code] Select Case App.StageCode
’ Set an app icon for Dev builds
’ Set an app icon for Alpha builds
’ Set an app icon for Beta builds
’ Set an app icon for Final builds
Here is a build script for an upcoming version of my app that needs a special icon (Mac OS of course):
[code] 'get paths
dim appPath as string = currentBuildLocation + “/” + shellEncode(currentBuildAppName)
if right(AppPath, 4) <> “.app” then appPath = appPath + “.app”
dim resourcesFolder as string = appPath + “/Contents/Resources/”
dim plistFile as string = appPath + “/Contents/Info.plist”
dim CountSlashes as Integer = CountFields(ProjectShellPath, “/”)
dim ProjectName as string = NthField(ProjectShellPath, “/”, CountSlashes)
dim ProjectPath as String = Left(ProjectShellPath, Len(ProjectShellPath) - Len(ProjectName))
'get name of icon Dim iconFileName as string = readValue(plistFile, "CFBundleIconFile") 'try to copy icon to correct place If trim(iconFileName) = "" then msgbox("There was an issue reading the apps plist file, the icon cannot be correctly installed.") elseif Instr(iconFileName, "installer") > 0 then dim IconPath as String = ProjectPath + "../Icons/pro\\ icns/installer.icns" call copyFile(IconPath, resourcesFolder + shellEncode(iconFileName), "Installing custom icon") else dim IconPath as String = ProjectPath + "../Icons/pro\\ icns/app.icns" call copyFile(IconPath, resourcesFolder + shellEncode(iconFileName), "Installing custom icon") End If '"/Users/beatrixwillius/Documents/\\ Datei/Development/Mail\\ Archiver/Icons/pro\\ icns/app.icns"
// Helper functions for this script
Function shellEncode(inValue as string) as string
Dim rvalue as string = replaceAll(inValue, " ", "\ ")
rvalue = replaceAll(rvalue, “&”, “\&”)
rvalue = replaceAll(rvalue, “-”, “\-”)
rvalue = replaceAll(rvalue, “(”, “\(”)
rvalue = replaceAll(rvalue, “)”, “\)”)
Function copyFile(inSource as string, inTarget as string, inMethodName as string) as boolean
return execute("/bin/cp -fR " + inSource + " " + inTarget, inMethodName)
Function readValue(plistFile as string, key as string) as string
return trim(DoShellCommand( "/usr/bin/defaults read " + plistfile + " " + key))
Sub msgBox(inMessage as string, inSecondLine as string = “”)
call showDialog(inMessage, inSecondLine, “OK”, “”, “”, 0)
Function execute(inCommand as string, inMethodName as string) as boolean
Dim result as string = DoShellCommand(inCommand)
if result <> “” then
msgbox("An error occurred while "+inMethodName, "Message: " + result)
Thanks @Beatrix Willius - unless I’m missing something this won’t get me access to Alpha/Beta etc, obviously I can have different scripts for Debug/Release but not at the level I’m looking for.
I’ve raised a feature request - it’s not exactly the highest of priorities(!) but xCode does this for beta versions and its great to have a visual clue as to whether your using a beta version of the product or not.
If Xojo could do this for the IDE as well, that would be awesome. When there is a beta version out I can have both the beta and production versions open and I can only tell which is which by clicking “About Xojo”
Not quite sure what the request is asking for ?
You cant set the icon at runtime. Thats built in so things like Launch Services can find it
You CAN badge the dock icon at runtime though
Updated the case - I never got an email stating the case needed info from me.
If Im building an alpha/beta version of the product it would be very nice to set a different app icon for that build so its visually obvious that its not a production version of the application. Much like xCode putting a Beta banner across its app icon for its betas."
As Norman said you can badge it, so why not badge it with “beta”?
[quote=234278:@Patrick Delaney]Updated the case - I never got an email stating the case needed info from me.
If Im building an alpha/beta version of the product it would be very nice to set a different app icon for that build so its visually obvious that its not a production version of the application. Much like xCode putting a Beta banner across its app icon for its betas."[/quote]
On OS X trivial in a postbuild step - just copy over a different ICNS file based on the app stage code property
Is what you’re seeking is a way to set 4 different icons (one each for dev beta alpha final) ?
Or just an “automatically badge the icons that get built in” so the ICNS on OS X is written with a badge ?
Just FYI Xcode literally uses a different icns file on os x for the betas that has the beta bade on it (and its named Xcode Beta)
Because I don’t want to do this at runtime…
I want to build with different icons so when a user sees the app icon on the dock/desktop or whatever they see what code stage that app has been built for.
Besides - if I want to do it at runtime (which I don’t) DockItem is OSX only and I’m unaware of a Windows/Linux alternative to that.
Sure - but that doesn’t help Windows/Linux. This is not Just OS X, this is for Windows and Linux as well.
YES - this is what I’m asking for. I want to have up to 4 sets of application icons to represent the various code stages, when I build the IDE sets the correct app icon from those 4.
English must be failing me as a first language today…
I just wanted to be clear as there at least 2 ways to do this
4 sets would be 40 images
But if it were possible to set up 1 icon + a different badge for dev, beta and alpha then there might only be one icon + 3 badges.
It may be 6 or 9 badges to account for different sized icons but its a lot less that way
Mine was more a comment on my inability to get the point across succinctly.
[quote=234285:@Norman Palardy]4 sets would be 40 images
But if it were possible to set up 1 icon + a different badge for dev, beta and alpha then there might only be one icon + 3 badges It Maybe 6 or 9 badges to account for different sized icons but its a lot less that way[/quote]
That’s an implementation thing, if there’s a better way to get it done - great - crack on
I dunno if thats why people said well just badge the dock icon because that CAN be done at runtime
But You want to be abel to identify alpha, beta, etc without having to run the app
That requires the icon actually BE badged in some fashion
Sort of for sure
I dont know if anyone would want a completely different icon for alpha, beta etc or just one with a badge on it
That would require different implementations
So this one may stew for a bit to see if we get any other feedback on it