iosreact-nativegithub-actionsfastlane

Can't build ios from react native app in fastlane and github actions


I want to automate the build of the IOS version from react native app using fastlane and github actions. I've followed this link for installing .p12 certifcate file and the provisioning profile file with extension .mobileprovision. However, when I run the fastlane on github actions it logs in to apple connect correctly and every thing is ok until the build_app step where it throws the following error: Error: No profiles for 'com.bimsaudi.atarcloud' were found: Xcode couldn't find any iOS App Development provisioning profiles matching 'com.bimsaudi.atarcloud'. Automatic signing is disabled and unable to generate a profile. To enable automatic signing, pass -allowProvisioningUpdates to xcodebuild. (in target 'Atar' from project 'Atar')

Here's my Fastfile:


default_platform(:ios)

platform :ios do
desc "Push a new beta build to TestFlight"
lane :beta do
  setup_ci

  auth_key_path = File.expand_path(File.join(File.dirname(__FILE__), '**.p8'))

  app_store_connect_api_key({
    key_id: "<key_id>",
    issuer_id: "<issuer_id>",
    key_filepath: auth_key_path,
  })
  increment_build_number(xcodeproj: "Atar.xcodeproj")
  build_app(workspace: "Atar.xcworkspace", scheme: "Atar")
  upload_to_testflight
end

lane :check_provisioning_profiles do
  setup_ci
  auth_key_path = File.expand_path(File.join(File.dirname(__FILE__), '**.p8'))

  app_store_connect_api_key({
    key_id: "<key_id>",
    issuer_id: "<issuer_id>",
    key_filepath: auth_key_path,
  })

  sigh(username: "<apple-username>")
end
  
end

And here's my .github/workflows/automation.yml file:

name: Test CD
on:
  push:
  workflow_dispatch:

jobs:
  build-ios:
    name: Build IOS
    runs-on: macOS-14

    steps:
      - name: Checkout repository
        uses: actions/checkout@v1

      - name: Install the Apple certificate and provisioning profile
        env:
          BUILD_CERTIFICATE_BASE64: ${{ secrets.BUILD_CERTIFICATE_BASE64 }}
          P12_PASSWORD: ${{ secrets.P12_PASSWORD }}
          BUILD_PROVISION_PROFILE_BASE64: ${{ secrets.BUILD_PROVISION_PROFILE_BASE64 }}
          KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
        run: |
          # create variables
          CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12
          PP_PATH=$RUNNER_TEMP/build_pp.mobileprovision
          KEYCHAIN_PATH=$RUNNER_TEMP/app-signing.keychain-db

          # import certificate and provisioning profile from secrets
          echo -n "$BUILD_CERTIFICATE_BASE64" | base64 --decode -o $CERTIFICATE_PATH
          echo -n "$BUILD_PROVISION_PROFILE_BASE64" | base64 --decode -o $PP_PATH

          # create temporary keychain
          security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
          security set-keychain-settings -lut 21600 $KEYCHAIN_PATH
          security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH

          # import certificate to keychain
          security import $CERTIFICATE_PATH -P "$P12_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH
          security set-key-partition-list -S apple-tool:,apple: -k "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH
          security list-keychain -d user -s $KEYCHAIN_PATH

          # apply provisioning profile
          mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
          cp $PP_PATH ~/Library/MobileDevice/Provisioning\ Profiles

      - name: Setup Node
        uses: actions/setup-node@v2
        with:
          node-version: '16.20.2'
          cache: 'yarn'

      - name: Install deps
        run: yarn --frozen-lockfile && yarn env

      - name: Install pods
        shell: bash
        run: cd ios/ && pod install && cd ..

      - name: Build IOS
        run: cd ios/ && fastlane ios check_provisioning_profiles && fastlane ios beta
        env:
          FASTLANE_USER: ${{ secrets.FASTLANE_USER }}
          FASTLANE_PASSWORD: ${{ secrets.FASTLANE_PASSWORD }}
          FASTLANE_SESSION: ${{ secrets.FASTLANE_SESSION }}
          # FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD: ${{ secrets.FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD }}
          MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}

Install app certificate and provisioning profile is ok

The sigh works

The provisioning profile installed

All the steps before build_app are ok

The beginning of build_app step

And, the error

And another pic for fastlane error


Solution

  • After a lot of investigations and searching. I found the solution here Github issue

    I used match and disabled automatic code signing with update_code_signing_settings and finally using the gym the way the link suggested.