Migration React Native v0.65 - Fastlane build fail for iOS "Archive failed" (Exit Status: 65) only on CircleCI

Working on migrating a mobile app from React Native 0.59.0 to 0.60.5 and adding support to AndroidX. The updated app works fine on both iOS and Android locally and the CircleCI build for Android is working fine. We use Fastlane and Gym to build and release our app.

The CircleCI build for iOS fails on CircleCI during the archive step. When running bundle exec fastlane ios build_release locally it works fine. The same way, we’ve tried archiving the app through XCode (same version as in CCI 10.2.1) locally and it also works fine.

The complete log of the build step can be seen here: https://gist.github.com/vincentnavetat/17adcdf4cd410f52e30e410d457d656f

The xcodebuild command that fails:
set -o pipefail && xcodebuild -workspace ./MyApp.xcworkspace -scheme MyApp -destination ‘generic/platform=iOS’ -archivePath /Users/distiller/Library/Developer/Xcode/Archives/2019-09-23/MyApp\ 2019-09-23\ 02.23.13.xcarchive archive | tee /Users/distiller/Library/Logs/gym/MyApp-MyApp.log | xcpretty

Fastlane environment:

Stack

Key Value
OS 10.14.4
Ruby 2.4.6
Bundler? false
Git git version 2.21.0
Installation Source ~/.gem/ruby/2.4.6/bin/fastlane
Host Mac OS X 10.14.4 (18E226)
Ruby Lib Dir ~/.rubies/ruby-2.4.6/lib
OpenSSL Version OpenSSL 1.0.2r 26 Feb 2019
Is contained false
Is homebrew false
Is installed via Fabric.app false
Xcode Path /Applications/Xcode-10.2.1.app/Contents/Developer/
Xcode Version 10.2.1

System Locale

Variable Value
LANG en_GB.UTF-8 :white_check_mark:
LC_ALL en_GB.UTF-8 :white_check_mark:
LANGUAGE

fastlane files:

`./fastlane/Fastfile`
# frozen_string_literal: true

# Customize this file, documentation can be found here:
# https://docs.fastlane.tools/actions/
# All available actions: https://docs.fastlane.tools/actions
# can also be listed using the `fastlane actions` command

# Change the syntax highlighting to Ruby
# All lines starting with a # are ignored when running `fastlane`

# If you want to automatically update fastlane if a new version is available:
# update_fastlane

# This is the minimum version number required.
# Update this, if you use features of a newer version

fastlane_version '2.67.0'

default_platform :ios

platform :ios do
  before_all do
    setup_circle_ci
  end

  desc 'Runs all the tests'
  lane :test do
    run_tests(scheme: "MyApp", skip_build: true)
  end

  desc 'Submit a new Beta Build to Apple TestFlight'
  desc 'This will also make sure the profile is up to date'
  lane :beta do
    sync_code_signing type: 'appstore' # see code signing guide for more information
    build_app scheme: 'MyApp'
    upload_to_testflight
  end

  desc 'Deploy a new version to the App Store'
  lane :release do
    sync_code_signing type: 'appstore' # see code signing guide for more information
    build_app scheme: 'MyApp'
    deliver(force: true)
    # frameit
  end

  desc "Build Release"
  lane :build_release do
    sync_code_signing type: 'appstore' # see code signing guide for more information
    build_app scheme: 'MyApp'
  end

  desc "Refresh DSyms"
  lane :refresh_dsyms do
    download_dsyms(min_version: "1.55.0")
    upload_symbols_to_bugsnag              # Upload them to Bugsnag
    clean_build_artifacts
  end

  # You can define as many lanes as you want

  after_all do |lane|
    # This block is called, only if the executed lane was successful

    # slack(
    #   message: "Successfully deployed new App Update."
    # )
  end

  error do |lane, exception|
    # slack(
    #   message: exception.message,
    #   success: false
    # )
  end
end

# More information about multiple platforms in fastlane: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform
# All available actions: https://docs.fastlane.tools/actions

# fastlane reports which actions are used. No personal data is recorded.
# Learn more at https://docs.fastlane.tools/#metrics

`./fastlane/Appfile`
app_identifier "" # The bundle identifier of your app
apple_id "" # Your Apple email address

team_id "" # Developer Portal Team ID

# you can even provide different app identifiers, Apple IDs and team names per lane:
# More information: https://docs.fastlane.tools/advanced/#appfile

fastlane gems

Gem Version Update-Status
fastlane 2.131.0 :white_check_mark: Up-To-Date

Loaded fastlane plugins:

Plugin Version Update-Status
fastlane-plugin-bugsnag 1.4.1 :white_check_mark: Up-To-Date
Loaded gems
Gem Version
did_you_mean 1.1.0
slack-notifier 2.3.2
rouge 2.0.7
xcpretty 0.3.0
terminal-notifier 2.0.0
terminal-table 1.8.0
plist 3.5.0
multipart-post 2.0.0
word_wrap 1.0.0
public_suffix 2.0.5
babosa 1.0.2
colored 1.2
highline 1.7.10
commander-fastlane 4.4.6
faraday 0.15.4
http-cookie 1.0.3
faraday-cookie_jar 0.0.6
gh_inspector 1.1.3
mini_magick 4.9.5
multi_xml 0.6.0
security 0.1.3
xcpretty-travis-formatter 1.0.0
faraday_middleware 0.13.1
naturally 2.2.0
simctl 1.6.5
jwt 2.1.0
uber 0.1.0
declarative 0.0.10
declarative-option 0.1.0
representable 3.0.4
retriable 3.1.2
multi_json 1.13.1
signet 0.11.0
memoist 0.16.0
os 1.0.1
googleauth 0.6.7
httpclient 2.8.3
google-api-client 0.23.9
digest-crc 0.4.1
google-cloud-storage 1.16.0
emoji_regex 1.0.1
nanaimo 0.2.6
colored2 3.1.2
claide 1.0.3
CFPropertyList 3.0.1
atomos 0.1.3
xcodeproj 1.12.0
unicode-display_width 1.6.0
addressable 2.7.0
tty-screen 0.7.0
tty-cursor 0.7.0
tty-spinner 0.9.1
excon 0.66.0
unf_ext 0.0.7.6
unf 0.1.4
domain_name 0.5.20190701
fastimage 2.1.7
json 2.2.0
rubyzip 1.2.4
dotenv 2.7.5
bundler 2.0.2
mime-types-data 3.2019.0904
mime-types 3.3
google-cloud-env 1.2.1
google-cloud-core 1.3.1
openssl 2.0.9
io-console 0.4.6
psych 2.2.2
xml-simple 1.1.5
git 1.5.0
fastlane-plugin-bugsnag 1.4.1