0

I'm currently using fastlane with github action to deploy my Flutter iOS apps to Testflight. I have all the keys and information matched up. However, the build keeps failing at phase Run Script.

`PhaseScriptExecution Run\ Script /Users/runner/Library/Developer/Xcode/DerivedData/Runner-avobjsyvghznfxgtyjuolmxrrfls/Build/Intermediates.noindex/ArchiveIntermediates/prod/IntermediateBuildFilesPath/Runner.build/Release-prod-iphoneos/Runner.build/Script-9740EEB61CF901F6004384FC.sh (in target 'Runner' from project 'Runner')`

The fastfile runs fine on my local machine (with the same keys set as ENV) but not on GitHub Action.

The script causing the issue is:

 `/bin/sh "${FLUTTER_ROOT}/packages/flutter_tools/bin/xcode_backend.sh" build` in the **Run Script** phase of Xcode

I tried adding {} around the FLUTTER ROOT but nothing changes.

I added configuration of my Project Runner Info but still same.

The code of my Github Workflow yaml is as followed:

name: Flutter CI

on:
  push:
    branches: xxx

jobs:
  deploy:
    name: Deploying to Testflight
    runs-on: macOS-latest
    
    steps:

      - name: Setup XCode on Machine    
        uses: maxim-lobanov/setup-xcode@v1
        with:
          xcode-version: '13.4'

      - name: Setup Flutter
        uses: subosito/flutter-action@v2.8.0
        with:
          channel: 'stable'
          flutter-version: '3.3.9'

      - name: Give permission to private repo
        uses: shaunco/ssh-agent@git-repo-mapping
        with:
          ssh-private-key: |
            ${{ secrets.SECRET_REPO_DEPLOY_KEY }}
          repo-mappings: | 
            github.com/anfin21/package_library

      - name: Checkout repository
        uses: actions/checkout@v1
    
      - name: Install packages
        run: flutter pub get 

      - name: Deploy iOS Beta to TestFlight via Fastlane
        uses: maierj/fastlane-action@v1.4.0
        with:
          lane: closed_beta
          subdirectory: ios
        env:
          APP_STORE_CONNECT_TEAM_ID: '${{ secrets.ITC_TEAM_ID }}'
          DEVELOPER_APP_ID: '${{ secrets.APPLICATON_ID }}'
          DEVELOPER_APP_IDENTIFIER: '${{ secrets.BUNDLE_IDENTIFIER }}'
          DEVELOPER_PORTAL_TEAM_ID: '${{ secrets.DEVELOPER_PORTAL_TEAM_ID }}'
          FASTLANE_APPLE_ID: '${{ secrets.FASTLANE_APPLE_EMAIL_ID }}'
          FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD: '${{ secrets.FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD }}'
          MATCH_PASSWORD: '${{ secrets.MATCH_PASSWORD }}'
          GIT_AUTHORIZATION: '${{ secrets.GIT_AUTHORIZATION }}'
          PROVISIONING_PROFILE_SPECIFIER: '${{ secrets.PROVISIONING_PROFILE_SPECIFIER }}'
          TEMP_KEYCHAIN_PASSWORD: '${{ secrets.TEMP_KEYCHAIN_PASSWORD }}'
          TEMP_KEYCHAIN_USER: '${{ secrets.TEMP_KEYCHAIN_USER }}'
          APPLE_KEY_ID: '${{ secrets.APPLE_KEY_ID }}'
          APPLE_ISSUER_ID: '${{ secrets.APPLE_ISSUER_ID }}'
          APPLE_KEY_CONTENT: '${{ secrets.APPLE_KEY_CONTENT }}'

The FastFile of my iOS is as followed:

default_platform(:ios)
DEVELOPER_APP_ID = ENV["DEVELOPER_APP_ID"]
DEVELOPER_APP_IDENTIFIER = ENV["DEVELOPER_APP_IDENTIFIER"]
PROVISIONING_PROFILE_SPECIFIER = ENV["PROVISIONING_PROFILE_SPECIFIER"]
TEMP_KEYCHAIN_USER = ENV["TEMP_KEYCHAIN_USER"]
TEMP_KEYCHAIN_PASSWORD = ENV["TEMP_KEYCHAIN_PASSWORD"]
APPLE_ISSUER_ID = ENV["APPLE_ISSUER_ID"]
APPLE_KEY_ID = ENV["APPLE_KEY_ID"]
APPLE_KEY_CONTENT = ENV["APPLE_KEY_CONTENT"]
GIT_AUTHORIZATION = ENV["GIT_AUTHORIZATION"]

def delete_temp_keychain(name)
  delete_keychain(
    name: name
  ) if File.exist? File.expand_path("~/Library/Keychains/#{name}-db")
end

def create_temp_keychain(name, password)
  create_keychain(
    name: name,
    password: password,
    unlock: false,
    timeout: 0
  )
end

def ensure_temp_keychain(name, password)
  delete_temp_keychain(name)
  create_temp_keychain(name, password)
end

platform :ios do

  lane :closed_beta do
    keychain_name = TEMP_KEYCHAIN_USER
    keychain_password = TEMP_KEYCHAIN_PASSWORD
    ensure_temp_keychain(keychain_name, keychain_password)

    
    api_key = app_store_connect_api_key(
      key_id: APPLE_KEY_ID,
      issuer_id: APPLE_ISSUER_ID,
      key_content: APPLE_KEY_CONTENT,            
      duration: 1200,            
      in_house: false
    )

    cocoapods(
      clean_install: true,
    )

    match(
      type: 'appstore',
      app_identifier: "#{DEVELOPER_APP_IDENTIFIER}",
      git_basic_authorization: Base64.strict_encode64(GIT_AUTHORIZATION),
      readonly: false,
      keychain_name: keychain_name,
      keychain_password: keychain_password,
      api_key: api_key
    )

    gym(
      configuration: "Release",
      sdk: "iphoneos16.1",
      workspace: "Runner.xcworkspace",
      scheme: "prod",
      export_method: "app-store",
      export_options: {
        provisioningProfiles: { 
            DEVELOPER_APP_ID => PROVISIONING_PROFILE_SPECIFIER
        }
      }
    )

    pilot(
      apple_id: "#{DEVELOPER_APP_ID}",
      app_identifier: "#{DEVELOPER_APP_IDENTIFIER}",
      skip_waiting_for_build_processing: true,
      skip_submission: true,
      distribute_external: false,
      notify_external_testers: false,
      ipa: "./Runner.ipa"
    )

    delete_temp_keychain(keychain_name)
  end
end
  • Hi! Please add your relevant workflow and all the relevant information as text, not images. Thanks! – Azeem Feb 10 '23 at 08:54
  • Hi! Thanks for the request, I have updated my question with the necessary information. Please have a look – Lam Kiet Vuong Feb 13 '23 at 02:42
  • Thanks! Could you please specify which step is failing? Does your workflow require to use `${FLUTTER_ROOT}/packages/flutter_tools/bin/xcode_backend.sh` and where has it been mentioned? This https://github.com/subosito/flutter-action doesn't mention `FLUTTER_ROOT` in the docs but it does export it in its [source](https://github.com/subosito/flutter-action/blob/dbf1fa04f4d2e52c33185153d06cdb5443aa189d/setup.sh#L229-L232). You might want to explore this path with `ls` command to make sure it's the right one that you're looking for. – Azeem Feb 13 '23 at 04:03
  • So in my Xcode there are quite a few of Build Phases, one in which run the script above, and It failed at that phase (steps). Again I should mention that the script failed on the CI machine but not on local. Should I specify a concrete Flutter Root path for the Xcode on The CI Machine ? – Lam Kiet Vuong Feb 13 '23 at 08:04
  • `FLUTTER_ROOT` should already be there according to the implementation. However, you can print it separately to make sure it points to the correct directory and that directory actually contains that shell script that you're invoking. – Azeem Feb 13 '23 at 09:59

0 Answers0