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