Skip to content

Instantly share code, notes, and snippets.

@GuillaumeFalourd
Last active May 24, 2024 11:59
Show Gist options
  • Save GuillaumeFalourd/ffe95365f4f72920d00f3b5bb55b64bb to your computer and use it in GitHub Desktop.
Save GuillaumeFalourd/ffe95365f4f72920d00f3b5bb55b64bb to your computer and use it in GitHub Desktop.

The issue seems indeed related to the system Keychain being locked on the GitHub Action runner, which is preventing the [CP] Embed Pods Frameworks step from completing. The setup_ci command is used to configure the CI environment, including setting up the necessary Keychain settings, but it needs to be combined with Fastlane's match to properly manage code signing certificates and provisioning profiles.

Understanding setup_ci and match

  1. setup_ci:
  • This command is designed to perform various CI-specific setup tasks. It includes unlocking the Keychain and setting up other CI-related configurations.
  1. match:
  • Fastlane's match is used for managing code signing across your team by storing your code signing identities and provisioning profiles in a Git repository. It handles fetching these certificates and profiles securely and ensures that they are properly configured on the CI machine. Steps to Resolve the Issue To properly set up setup_ci and match, you need to perform the following steps:

Set Up match

  • Create a private GitHub repository to store your code signing certificates and provisioning profiles.
  • Run fastlane match init locally to initialize match and configure it to use your private GitHub repository.
  • Run fastlane match development, fastlane match adhoc, and fastlane match appstore locally to store your certificates and profiles in the repository.

Configure Fastlane on GitHub Actions

  • Update your Fastlane lane to include match commands for fetching the certificates and profiles.
  • Ensure setup_ci is called correctly to unlock the Keychain.

Revised version of your Fastlane lane incorporating match and setup_ci

platform :ios do
  desc "Description of your lane"
  lane :staging do
    puts "iOS staging build"
    setup_ci # Ensure CI environment is properly configured

    # Fetch the code signing certificates and provisioning profiles
    match(type: "development")
    match(type: "adhoc")
    match(type: "appstore")

    clean_build_artifacts
    disable_automatic_code_signing(path: "./ios/myapp.xcodeproj")

    build_app(
      scheme: "myapp",
      workspace: "./ios/myapp.xcworkspace",
      export_options: {
        signingStyle: "manual",
        provisioningProfiles: {
          "com.myapp" => "dc8421d4-d9f6-4357-925d-64a89c929734",
          "com.myapp.application" => "Distribution",
          "com.myapp.application.AB24Intents" => "AB24Intents",
          "com.myapp.application.ABRPWidget" => "ABRPWidget"
        }
      },
      clean: true
    )
  end
end

GitHub Actions Workflow Configuration

Ensure your GitHub Actions workflow has the necessary environment variables and secrets configured for Fastlane and match:

Secrets

  • MATCH_PASSWORD: The password for your certificates.
  • MATCH_GIT_URL: The URL to your private GitHub repository for match.

Example Workflow:

name: iOS CI

on:
  push:
    branches:
      - main

jobs:
  build:
    runs-on: macos-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Set up Ruby
        uses: ruby/setup-ruby@v1
        with:
          ruby-version: 3.3.x

      - name: Install dependencies
        run: bundle install

      - name: Build and sign iOS app
        env:
          MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}
          MATCH_GIT_URL: ${{ secrets.MATCH_GIT_URL }}
        run: bundle exec fastlane staging

Explanation

  • setup_ci: This command will unlock the Keychain on the CI machine.
  • match: These commands fetch the necessary certificates and provisioning profiles from your private repository.

By correctly setting up and using match alongside setup_ci, you ensure that your GitHub Action runner has the necessary credentials and provisioning profiles, and that the Keychain is unlocked, allowing the build process to proceed without hanging at the [CP] Embed Pods Frameworks step.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment