EAS Build fails at Fastlane step

I am struggling to get an EAS build working for iOS in a project that has multiple different schemes. Running the app locally in either Debug or Release mode works fine (when using the cli).

There are 2 errors which look related to the Xcode “Copy Bundle Resources”, one is for main.jsbundle, and the other for a GoogleService-Info.plist file.

Creating Gymfile
Gymfile created
Successfully loaded '/Users/expo/workingdir/build/ios/Gymfile' 📄
+-----------------------+---------------------------------------------------------------------------------------------------------------------------------------------+
|                                                                  Detected Values from './Gymfile'                                                                   |
+-----------------------+---------------------------------------------------------------------------------------------------------------------------------------------+
| suppress_xcode_output | true                                                                                                                                        |
| clean                 | false                                                                                                                                       |
| scheme                | UAT                                                                                                                                         |
| export_options        |                                                                                                                                             |
| export_xcargs         | OTHER_CODE_SIGN_FLAGS="--keychain /var/folders/97/73j93h690g9gdn54bh_zskm40000gn/T/turtle-v2-cb54236e-1c52-469b-83b8-0ba455aa90cc.keychain" |
| disable_xcpretty      | true                                                                                                                                        |
| output_directory      | ./build                                                                                                                                     |
+-----------------------+---------------------------------------------------------------------------------------------------------------------------------------------+
Resolving Swift Package Manager dependencies...
$ xcodebuild -resolvePackageDependencies -workspace ./Payright.xcworkspace -scheme UAT
▸ Command line invocation:
▸     /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -resolvePackageDependencies -workspace ./Payright.xcworkspace -scheme UAT
▸ resolved source packages:
$ xcodebuild -showBuildSettings -workspace ./Payright.xcworkspace -scheme UAT
Command timed out after 3 seconds on try 1 of 4, trying again with a 6 second timeout...
Detected provisioning profile mapping: {:"com.payright.customer.uat"=>"dad57929-030b-444f-9f1e-9dba7ede4a25"}
+---------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------+
|                                                                                           Summary for gym 2.178.0                                                                                           |
+---------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------+
| workspace                                                     | ./Payright.xcworkspace                                                                                                                      |
| scheme                                                        | UAT                                                                                                                                         |
| clean                                                         | false                                                                                                                                       |
| output_directory                                              | ./build                                                                                                                                     |
| output_name                                                   | Payright                                                                                                                                    |
| silent                                                        | false                                                                                                                                       |
| skip_package_ipa                                              | false                                                                                                                                       |
| skip_package_pkg                                              | false                                                                                                                                       |
| export_options.method                                         | app-store                                                                                                                                   |
| export_options.provisioningProfiles.com.payright.customer.uat | dad57929-030b-444f-9f1e-9dba7ede4a25                                                                                                        |
| export_xcargs                                                 | OTHER_CODE_SIGN_FLAGS="--keychain /var/folders/97/73j93h690g9gdn54bh_zskm40000gn/T/turtle-v2-cb54236e-1c52-469b-83b8-0ba455aa90cc.keychain" |
| build_path                                                    | /Users/expo/Library/Developer/Xcode/Archives/2021-05-02                                                                                     |
| result_bundle                                                 | false                                                                                                                                       |
| buildlog_path                                                 | ~/Library/Logs/gym                                                                                                                          |
| destination                                                   | generic/platform=iOS                                                                                                                        |
| suppress_xcode_output                                         | true                                                                                                                                        |
| disable_xcpretty                                              | true                                                                                                                                        |
| skip_profile_detection                                        | false                                                                                                                                       |
| skip_package_dependencies_resolution                          | false                                                                                                                                       |
| disable_package_automatic_updates                             | false                                                                                                                                       |
| use_system_scm                                                | false                                                                                                                                       |
| xcode_path                                                    | /Applications/Xcode.app                                                                                                                     |
+---------------------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------+
$ set -o pipefail && xcodebuild -workspace ./Payright.xcworkspace -scheme UAT -destination 'generic/platform=iOS' -archivePath /Users/expo/Library/Developer/Xcode/Archives/2021-05-02/Payright\ 2021-05-02\ 19.45.12.xcarchive archive | tee /Users/expo/Library/Logs/gym/Payright-UAT.log > /dev/null
▸ ** ARCHIVE FAILED **
▸ The following build commands failed:
▸ 	CpResource /Users/expo/workingdir/build/ios/main.jsbundle /Users/expo/Library/Developer/Xcode/DerivedData/Payright-clzduyxqmldazhdcfbgfdjprkqyq/Build/Intermediates.noindex/ArchiveIntermediates/UAT/InstallationBuildProductsLocation/Applications/Payright\ UAT.app/main.jsbundle
▸ 	CopyPlistFile /Users/expo/Library/Developer/Xcode/DerivedData/Payright-clzduyxqmldazhdcfbgfdjprkqyq/Build/Intermediates.noindex/ArchiveIntermediates/UAT/InstallationBuildProductsLocation/Applications/Payright\ UAT.app/GoogleService-Info.plist /Users/expo/workingdir/build/ios/Payright/GoogleService-Info.plist
▸ (2 failures)
** ARCHIVE FAILED **
The following build commands failed:
	CpResource /Users/expo/workingdir/build/ios/main.jsbundle /Users/expo/Library/Developer/Xcode/DerivedData/Payright-clzduyxqmldazhdcfbgfdjprkqyq/Build/Intermediates.noindex/ArchiveIntermediates/UAT/InstallationBuildProductsLocation/Applications/Payright\ UAT.app/main.jsbundle
	CopyPlistFile /Users/expo/Library/Developer/Xcode/DerivedData/Payright-clzduyxqmldazhdcfbgfdjprkqyq/Build/Intermediates.noindex/ArchiveIntermediates/UAT/InstallationBuildProductsLocation/Applications/Payright\ UAT.app/GoogleService-Info.plist /Users/expo/workingdir/build/ios/Payright/GoogleService-Info.plist
(2 failures)
Exit status: 65
+-------------+-------------------------+
|           Build environment           |
+-------------+-------------------------+
| xcode_path  | /Applications/Xcode.app |
| gym_version | 2.178.0                 |
| sdk         | iPhoneOS14.4.sdk        |
+-------------+-------------------------+
Looks like fastlane ran into a build/archive error with your project
It's hard to tell what's causing the error, so we wrote some guides on how
to troubleshoot build and signing issues: https://docs.fastlane.tools/codesigning/getting-started/
Before submitting an issue on GitHub, please follow the guide above and make
sure your project is set up correctly.
fastlane uses `xcodebuild` commands to generate your binary, you can see the
the full commands printed out in yellow in the above log.
Make sure to inspect the output above, as usually you'll find more error information there
[stderr] [!] Error building the application - see the log above
Error: Fastlane build failed with unknown error. Please refer to the "Run fastlane" and "Xcode Logs" phases.
Fastlane errors in most cases are not printed at the end of the output, so you may not find any useful information in the last lines of output when looking for an error message.

Would anyone be able to help on this? If I remove these I can build successfully and submit to Testflight, but the app crashes at the SplashScreen.

If I try to do a release build on Xcode in my local setup Xcode throws this error:

*** Terminating app due to uncaught exception 'RCTFatalException: Unhandled JS Exception: TypeError: The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type undefined', reason: 'Unhandled JS Exception: TypeError: The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type undefined, stack:

Running the app locally in either Debug or Release mode works fine (when using the cli).

If I try to do a release build on Xcode in my local setup Xcode throws this error:

So it’s failing when you archive, but not when you build?

Probably the best place to start with this is to get the local build through Xcode working, then tackle EAS. If it works locally, it’ll most likely work on EAS. expo prebuild should handle the setup of your google services file for you, did you modify where that file is or change your build steps in xcode at all?

Hi there

Looks like the issue was trying to use .env and .env.uat etc files which i loaded before running the debug / release configs, but this does not work when trying to create archives with EAS for some reason. And also removing those copy bundle resources commands helped. Getting it to build on xcode successfully helped. Thanks @charliecruzan

Regards

1 Like

For env variables or secrets in EAS Build, you can use Secrets- Environment variables and secrets - Expo Documentation :+1: