Automating signing files management with Codemagic CLI tools

How to code sign iOS apps

Automating signing files management with Codemagic CLI tools

Codemagic offers a set of utilities known as Codemagic CLI tools for facilitating the building and code signing of iOS apps built with native tooling, React Native or Flutter. The CLI tools are used for building and code signing during Codemagic builds but can be just as easily used on a local Mac or in other remote machines.

To use Codemagic CLI tools for code signing and creating an .ipa archive, follow these steps.

  1. Install Codemagic CLI tools using pip.
    pip3 install codemagic-cli-tools
  2. Download the required certificates and provisioning profiles using the following command.
    app-store-connect fetch-signing-files <"bundle_id">

    The bundle ID will be used to download the matching code signing files. Instead of the bundle ID, you can also use "\$(xcode-project detect-bundle-id)" to detect the bundle ID from Xcode configuration. Use the --create flag to create the signing files if they’re missing. Read more about the app-store-connect utility.

  3. Prepare the project for code signing by running
    xcode-project use-profiles

    Read more about the xcode-project utility.

  4. Build and export the .ipa archive by specifying your project and scheme.
    xcode-project build-ipa --project "MyXcodeProject.xcodeproj" --scheme "MyScheme"

    Use --workspace "MyXcodeWorkspace.xcworkspace" to specify a workspace instead. Read more about the build-ipa action.

The end result will be a code-signed .ipa archive that you can distribute to testers or publish to App Store Connect.