Build script to add non-release version to iOS version string

I’ve been frustrated in the past that I wasn’t able to use Xojo’s “Non Release Version” as part of the version number that’s submitted to the App Store, because I wanted to be able to use it during my company’s beta testing process. This thread got me closer to being able to do that (thanks @Bob_Gordon !) but I’ve made a few modifications that make it comply with the App Store’s version number requirements and work with apps that have a space in their name.

Put this build script between the “Build” and “Sign” stages. It works with both debug and release builds.

Dim v(), longVersion, shortVersion, result, appName, appLocation, cmd As String

// Build version number strings
v.append PropertyValue("App.MajorVersion")
v.append "."
v.append PropertyValue("App.MinorVersion")
v.append "."
v.append PropertyValue("App.BugVersion")
shortVersion  = Join(v,"")
v.append "."
v.append PropertyValue("App.NonReleaseVersion")
longVersion = Join(v,"")

appName = CurrentBuildAppName
appLocation = CurrentBuildLocation + "/" + appName.Replace( " ", "\ " )

// Set the long version number
cmd = "/usr/libexec/PlistBuddy -c ""Set :CFBundleVersion <build>"" " + appLocation + "/Info.plist"
cmd = cmd.Replace( "<build>", "'" + longVersion + "'" )
result = DoShellCommand(cmd)
if result <> "" then
  print "Long version setting failed: " + cmd + "       " + result
end if

// Set the short version number
cmd = "/usr/libexec/PlistBuddy -c ""Set :CFBundleShortVersionString <build>"" " + appLocation + "/Info.plist"
cmd = cmd.Replace( "<build>", "'" + shortVersion + "'" )
result = DoShellCommand(cmd)
if result <> "" then
  print "Short version setting failed: " + cmd + "       " + result
end if
5 Likes