Building with Enterprise profile

[quote=439424:@Bob Keeney]Pay it forward if you can.

This forum is a Xojo community treasure chest.[/quote]

In the spirit of paying it forward, I’ve worked out a way to mostly automate this using a build script. This is also added as another entry in Feedback case #47975 for those who search there.

The script relies in part on a shell script available as part of XReSign available on GitHub here, at least as of the time of this writing:

https://github.com/xndrs/XReSign

Specifically it uses the file https://github.com/xndrs/XReSign/blob/master/XReSign/Scripts/xresign.sh

But it is probably always best to clone or download the then-current project, which also contains a GUI app as well as the shell script.

Preliminary steps, needed just once, before adding to any iOS project:

  1. Clone or download the XReSign project linked above
  2. Copy xresign.sh to some location; I simply put in /Applications
  3. Make that file executable; for my installation I used:
chmod +x /Applications/xresign.sh

For any Xojo iOS project needing an Enterprise certificate signed app:

  1. Set project’s iOS build settings to code signing team None and do NOT build for App Store
  2. Use menu Insert > Build Step > Script
  3. Rename from Script1 to Resign (optional)
  4. Insert the block of code given below
  5. Modify string literals in a few spots as appropriate
  6. Provisioning profile can either be a downloaded file or imported UUID
  7. You can optionally change the bundle ID too
  8. Sample script below assumes names like MyCompany and MyApp

Note that the certificate name should be exactly how it is spelled in Keychain Access, and the keychain must include the private key as well.

Dim command as String
Dim result as String

' Convert *.app to unsigned.ipa
command = "cd " + CurrentBuildLocation + "; mkdir Payload; "
command = command + " mv *.app Payload; zip -rm unsigned.ipa Payload/*.*"
result = DoShellCommand(command)

' Prepare command to resign it
command = "/Applications/xresign.sh "
command = command + " -s " + CurrentBuildLocation + "/unsigned.ipa "

' Add name of certificate to be used for signing
command = command + " -c ""iPhone Distribution: MyCompany, LLC"" "

' Add name of provisioning profile to be used either as some download location
command = command + " -p ""~/Downloads/MyApp.mobileprovision"" "

' or else as an already imported provisioning profile
' command = command + " -p ""~/Library/MobileDevice/Provisioning Profiles/"
' command = command + "abcdef12-1234-abcd-1234-abcedf123456.mobileprovision"" "

' Optional change bundle identifier
'command = command + " -b com.mycompany.newID"

' Resign it
result = DoShellCommand(command)

' Clean up temporary folders
command = "cd " + CurrentBuildLocation + "; rmdir Payload; rmdir tmp"
result = DoShellCommand(command)

After building, the IOS folder should contain both unsigned.ipa and *-resigned.ipa which can be renamed to just *.ipa for distribution

Edit: Added feedback case number instead of just link.