Are "Validate" and "Distribute" steps necessary for Direct Distribution of a Mac app?

StackOverflow https://stackoverflow.com/questions/22600524

  •  19-06-2023
  •  | 
  •  

Question

I am working to automate the process of releasing a Mac application using xCode 5. The app is only distributed outside of the Mac App Store (Direct Distribution). I know that I can add a Run Script to be executed during the Build Phase to automate the process. I am currently using a ruby script from Craig Williams for appcast automation. The script is here: https://github.com/CraigWilliams/appcastautomation/blob/SnowLeopard/appcast_automation.rb

My question is: Are the Validate and Distribute steps necessary? Provided that code signing is completed, can I simply run the automation script and use the .zip file produced by the script or must I go through the steps outlined below and then process the "Exported" app using the script?

My current process is as follows:

  1. Select "Archive" from xCode's Product menu.
  2. Open Organizer and press "Validate" button.
  3. Press "Distribute" and choose "Export Developer ID-signed Application" then press "Next".
  4. Select my Developer ID code signing certificate.
  5. Press "Export" to save the MyApp.app file.

Once I have the "Exported" .app file, I am manually running the script via Terminal to create the .zip file required for Sparkle appcast. I am hoping to skip the xCode export process as a first step towards automated distribution.

Was it helpful?

Solution

Yes, it is possible to completely automate an app release process without needing to go through Xcode's Organizer to "Validate" and "Distribute" an application for Direct Distribution. It requires several Run Script Build Phases to be added to the target in XCode. This is what I ended up doing...

1) The first step was to code sign all frameworks AND the application bundle so that when the appcast automation script runs, the app that gets zipped is already code signed. This omits the need to export the app via Organizer. This Run Script is added immediately after all "copy" build phases.

IDENTITY="Developer ID Application: My Great Company."
FRAMEWORK_LOC="${BUILT_PRODUCTS_DIR}"/"${FRAMEWORKS_FOLDER_PATH}"
codesign --verbose --force --sign "$IDENTITY" "$FRAMEWORK_LOC/Growl.framework/Versions/A"
codesign --verbose --force --sign "$IDENTITY" "$FRAMEWORK_LOC/Sparkle.framework/Versions/A"
codesign --verbose --force --sign "$IDENTITY" "$BUILT_PRODUCTS_DIR/$FULL_PRODUCT_NAME"

2) The 2nd Run Script executes a Ruby script that creates a .zip file of the app and an .xml file for appcast distribution via Sparkle. The original script came from here: https://github.com/CraigWilliams/appcastautomation/blob/SnowLeopard/appcast_automation.rb

I have customized the script to also copy the unzipped app to another folder that is later used to automagically create a .dmg file.

The 2nd run script is simply:

script_file="appcast_automation.rb"
$SRCROOT/$PRODUCT_NAME/${script_file}

3) The 3rd Run Script creates a .dmg file with a custom icon, background, version, license agreement, etc... I use DropDMG's command-line tool (http://c-command.com/dropdmg/) to create the .dmg file. I have added the wm_license and wm_layout directories into the Xcode project so the script has access to them and they are versioned using git.

This Run Script is set to "Run script only when installing".

VERSIONNUM=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${PROJECT_DIR}/${INFOPLIST_FILE}")
layout_folder="${PROJECT_DIR}/${PROJECT_NAME}/wm_layout"
license_folder="${PROJECT_DIR}/${PROJECT_NAME}/wm_license"
dmg_folder="/Users/username/Desktop/WindowMizer/${PROJECT_NAME}_$VERSIONNUM/${PROJECT_NAME}"
dropdmg --custom-icon --license-folder=$license_folder --layout-folder=$layout_folder $dmg_folder

The list of Run Scripts and the automation files in Xcode looks like this:

enter image description here

So, by simply choosing "Archive" in Xcode, I end up with: a .zip file and .xml files for automatic updates via Sparkle and a .dmg file for first-time (new) downloads. The end result is this...

Final results

Everything is code-signed and ready to deploy. The only thing left to do is to upload the files to the server, which could be automated, but I prefer to do that part manually.

When time permits, and if I am allowed, I will post my modified copy of appcast_automation.rb in a github repository and add a link to it from here.

Hope this helps someone else!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top