Change App Icons with script before build?

Is there a way to set the App Icons before one builds it?

I have an app which can be configured to be used in specific client segments, and therefor I will change name and icon and configuration. One build shall produce the app “Seminar Pro”, the next build the app “Medicenter Pro” and again another the app “Shopman Pro”.

I want to automate the build process and I don’t see yet how to set App Icons programmatically.

Possible workaround: If there is no automated way in Xojo, I guess I can do it with AppWrapper after the build.

EDIT: The build target is macOS

With a script ? Xojo IDE says the application does not exists.

After the build: yes.
Edit: Using a Post Build Script: Yes.

For the conditional part (to copy the appropriate App.icns and App name): I do not know. Maybe in the Xojo Automation doc (where ?)

Edit:
Maybe: http://developer.xojo.com/userguide/ide-scripting-building-commands ?

Probably not the way to go for your specific need: no real script can be added to that Post Build Script. Mine only contains the “copy the App Icon" and I do not found how to add lines of scripts (to modify App.Name).
Sorry.

Of course, you can change the icon in a build script. What you can’t do is change the name. For this you need an IDE communicator script.

Code for changing the icon:

[code]if ConstantValue(“App.kMaxVersion”) = “1” then

'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(currentBuildAppName, “installer”) > 0 then
dim IconPath as String = ProjectPath + “…/Icons/pro\ icns/installer.icns”
call copyFile(IconPath, resourcesFolder + shellEncode(iconFileName) + “.icns”, “Installing custom icon”)
else
dim IconPath as String = ProjectPath + “…/Icons/pro\ icns/app.icns”
call copyFile(IconPath, resourcesFolder + shellEncode(iconFileName) + “.icns”, “Installing custom icon”)
End If

end if

// 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, “)”, “\)”)
return rvalue
End Function

Function copyFile(inSource as string, inTarget as string, inMethodName as string) as boolean
return execute("/bin/cp -fR " + inSource + " " + inTarget, inMethodName)
End Function

Function readValue(plistFile as string, key as string) as string
return trim(DoShellCommand( "/usr/bin/defaults read " + plistfile + " " + key))
End Function

Sub msgBox(inMessage as string, inSecondLine as string = “”)
call showDialog(inMessage, inSecondLine, “OK”, “”, “”, 0)
End Sub

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)
return false
else
return true
end if
End Function[/code]

Code for changing the name:

dim theVersion as String = "0" ConstantValue("App.kMaxVersion") = theVersion

xojo_projects have their icon information stored in the .xojo_resources file, located in same directory as the .xojo_project. we use a shell script to remove the default .xojo_resources, and replace with one containing the icons for the specific build prior to loading the xojo_project.

edit - rbres was used for rbvcp, try the .xojo_resources instead

Thank you guys! Super Vorlage, Beatrix!

and for the target Windows ?