6

I am using fastlane in github actions to build my project, this is my github actions script:

name: Cruise-CI

on:
  push:
    branches: [ main ]

jobs:
  build:
    runs-on: macos-latest
    steps:
    - uses: actions/checkout@v2
    - uses: actions/setup-java@v1
      with:
        java-version: '12.x'
    - uses: subosito/flutter-action@v1
      with:
        flutter-version: '1.22.5'
    - name: Select Xcode version
      run: sudo xcode-select -s '/Applications/Xcode_12.1.app/Contents/Developer'
    - name: Bundle install
      run: cd ./ios && bundle install && bundle update fastlane
    - name: Install tools
      run: |
       flutter precache
       flutter pub get
       cd ./ios && pod repo update && pod install
    #- run: flutter pub get
    #- run: flutter build apk
    #- run: flutter build ios --release --no-codesign
    - name: Setup SSH Keys and known_hosts for fastlane match
      run: |
        SSH_PATH="$HOME/.ssh"
        mkdir -p "$SSH_PATH"
        touch "$SSH_PATH/known_hosts"
        echo "$PRIVATE_KEY" > "$SSH_PATH/id_rsa"
        chmod 700 "$SSH_PATH"
        ssh-keyscan github.com >> ~/.ssh/known_hosts
        chmod 600 "$SSH_PATH/known_hosts"
        chmod 600 "$SSH_PATH/id_rsa"
        eval $(ssh-agent)
        ssh-add "$SSH_PATH/id_rsa"
      env:
        PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
    - name: Deploy to TestFlight/PGY
      run: |
        cd ./ios && bundle exec fastlane beta
      env:
        APPLE_ID: ${{ secrets.APPLE_ID }}
        GIT_URL: ${{ secrets.GIT_URL }}
        PGY_USER_KEY: ${{ secrets.PGY_USER_KEY }}
        PGY_API_KEY: ${{ secrets.PGY_API_KEY }}
        TEAM_ID: ${{ secrets.TEAM_ID }}
        ITC_TEAM_ID: ${{ secrets.ITC_TEAM_ID }}
        FASTLANE_USER: ${{ secrets.FASTLANE_USER }}
        FASTLANE_PASSWORD: ${{ secrets.FASTLANE_PASSWORD }}
        FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD: ${{ secrets.FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD }}
        FASTLANE_SESSION: ${{ secrets.FASTLANE_SESSION }}
        MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}
        MATCH_KEYCHAIN_NAME: ${{ secrets.MATCH_KEYCHAIN_NAME }}
        MATCH_KEYCHAIN_PASSWORD: ${{ secrets.MATCH_KEYCHAIN_PASSWORD }}
        DELIVER_ITMSTRANSPORTER_ADDITIONAL_UPLOAD_PARAMETERS: ${{ secrets.DELIVER_ITMSTRANSPORTER_ADDITIONAL_UPLOAD_PARAMETERS }}

and this is my Fastfile script:

update_fastlane

default_platform(:ios)

platform :ios do
  desc "Push a new beta build to pgy"
  before_all do
    ENV["CACHE_GIT_URL"] = ENV["GIT_URL"]
  end

  lane :beta do
    xcode_select('/Applications/Xcode_12.1.app')
    if is_ci
      create_keychain(
        name: ENV['MATCH_KEYCHAIN_NAME'],
        password: ENV["MATCH_KEYCHAIN_PASSWORD"],
        default_keychain: true,
        unlock: true,
        timeout: 3600,
        lock_when_sleeps: false
      )
    end

    match(
      app_identifier: ENV["APP_IDENTIFIER"],
      git_url: ENV["GIT_URL"],
      type: "adhoc",
      readonly: is_ci,
      keychain_name: ENV['MATCH_KEYCHAIN_NAME'],
      keychain_password: ENV["MATCH_KEYCHAIN_PASSWORD"]
    )

    build_app(
        workspace: "Runner.xcworkspace",
        scheme: "Runner",
        export_method: "ad-hoc"
    )

    pgyer(
        api_key: ENV['PGY_API_KEY'],
        user_key: ENV['PGY_USER_KEY']
    )
  end
end

but when runs in github actions shows this error:

** ARCHIVE FAILED **


The following build commands failed:
    PhaseScriptExecution Run\ Script /Users/runner/Library/Developer/Xcode/DerivedData/Runner-gzzbtgmsqethlzedjqlbspydxjjv/Build/Intermediates.noindex/ArchiveIntermediates/Runner/IntermediateBuildFilesPath/Runner.build/Release-iphoneos/Runner.build/Script-9740EEB61CF901F6004384FC.sh
(1 failure)
[04:51:35]: Exit status: 65
[04:51:35]: 
[04:51:35]: Maybe the error shown is caused by using the wrong version of Xcode
[04:51:35]: Found multiple versions of Xcode in '/Applications/'
[04:51:35]: Make sure you selected the right version for your project
[04:51:35]: This build process was executed using '/Applications/Xcode_12.1.app'
[04:51:35]: If you want to update your Xcode path, either
[04:51:35]: 
[04:51:35]: - Specify the Xcode version in your Fastfile
[04:51:35]: ▸ xcversion(version: "8.1") # Selects Xcode 8.1.0
[04:51:35]: 
[04:51:35]: - Specify an absolute path to your Xcode installation in your Fastfile
[04:51:35]: ▸ xcode_select "/Applications/Xcode8.app"
[04:51:35]: 
[04:51:35]: - Manually update the path using
[04:51:35]: ▸ sudo xcode-select -s /Applications/Xcode.app
[04:51:35]: 

+---------------+------------------------------+
|              Build environment               |
+---------------+------------------------------+
| xcode_path    | /Applications/Xcode_12.1.app |
| gym_version   | 2.171.0                      |
| export_method | ad-hoc                       |
| sdk           | iPhoneOS14.1.sdk             |
+---------------+------------------------------+

[04:51:35]: ▸ ../../../hostedtoolcache/flutter/1.22.5-stable/x64/packages/flutter/lib/src/widgets/scroll_view.dart:588:9: Context: Found this candidate, but the arguments don't match.
[04:51:35]: ▸   const CustomScrollView({
[04:51:35]: ▸         ^^^^^^^^^^^^^^^^
[04:51:35]: ▸ Command PhaseScriptExecution failed with a nonzero exit code
[04:51:35]: 
[04:51:35]: ⬆️  Check out the few lines of raw `xcodebuild` output above for potential hints on how to solve this error
[04:51:35]: 📋  For the complete and more detailed error log, check the full log at:
[04:51:35]: 📋  /Users/runner/Library/Logs/gym/Runner-Runner.log
[04:51:35]: 
[04:51:35]: Looks like fastlane ran into a build/archive error with your project
[04:51:35]: It's hard to tell what's causing the error, so we wrote some guides on how
[04:51:35]: to troubleshoot build and signing issues: https://docs.fastlane.tools/codesigning/getting-started/
[04:51:35]: Before submitting an issue on GitHub, please follow the guide above and make
[04:51:35]: sure your project is set up correctly.
[04:51:35]: fastlane uses `xcodebuild` commands to generate your binary, you can see the
[04:51:35]: the full commands printed out in yellow in the above log.
[04:51:35]: Make sure to inspect the output above, as usually you'll find more error information there
[04:51:35]: 
+------------------------------------+--------------------------------------------------------+
|                                        Lane Context                                         |
+------------------------------------+--------------------------------------------------------+
| DEFAULT_PLATFORM                   | ios                                                    |
| PLATFORM_NAME                      | ios                                                    |
| LANE_NAME                          | ios beta                                               |
| KEYCHAIN_PATH                      | ~/Library/Keychains/***                     |
| ORIGINAL_DEFAULT_KEYCHAIN          | "/Users/runner/Library/Keychains/login.keychain-db"    |
| SIGH_PROFILE_TYPE                  | ad-hoc                                                 |
| MATCH_PROVISIONING_PROFILE_MAPPING | {"com.earth.dolphin"=>"match AdHoc com.earth.dolphin"} |
+------------------------------------+--------------------------------------------------------+
[04:51:35]: Error building the application - see the log above

I have already tried to specify the version of xcode in fastlane file like this:

xcode_select('/Applications/Xcode_12.1.app')

but still not work, what should I do to fix this? I also tried to change the xcode version to 12.3 follow this doc like this:

xcode_select('/Applications/Xcode_12.3.app')

still now work.

1 Answer 1

7

You are running on the latest MacOS image (which, at time of writing, is macos-10.15 with Xcode 12.4.0.0.1.1610135815—see installed tools):

 jobs:
  build:
    runs-on: macos-latest

But you are trying to select a specific version of Xcode to use:

- name: Select Xcode version
      run: sudo xcode-select -s '/Applications/Xcode_12.1.app/Contents/Developer'

The latest MacOS version (and the installed Xcode version) are liable to change if you use the -latest suffix when specifying the runs-on image.

Ensure that your MacOS and Xcode versions are compatible or just remove the Select Xcode version step entirely.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.