EAS IOS build fails: "Metro encountered an error: Cannot read property 'transformFile' of undefined"

I’m working on a managed expo app and I use eas services. I try to make an internal distribution build, on android it’s ok but on my ios build fail with this error :

Metro encountered an error:
    Cannot read property 'transformFile' of undefined
    ▸ 	PhaseScriptExecution Bundle\ React\ Native\ code\ and\ images /Users/expo/Library/Developer/Xcode/DerivedData/greengot-djveyphpwyosjubjkipdmcftptmp/Build/Intermediates.noindex/ArchiveIntermediates/greengot/IntermediateBuildFilesPath/greengot.build/Debug-iphoneos/greengot.build/Script-00DD1BFF1BD5951E006B06BC.sh

Here is the diff version I’m using:

"expo": "^41.0.0"
"react": "^17.0.2"
"react-native": "https://github.com/expo/react-native/archive/sdk-41.0.0.tar.gz"

and here is the fastlane step:


        Creating Gymfile
        Gymfile created
        Successfully loaded '/Users/expo/workingdir/build/ios/Gymfile' 📄
        +-----------------------+---------------------------------------------------------------------------------------------------------------------------------------------+
        |                                                                  Detected Values from './Gymfile'                                                                   |
        +-----------------------+---------------------------------------------------------------------------------------------------------------------------------------------+
        | suppress_xcode_output | true                                                                                                                                        |
        | clean                 | false                                                                                                                                       |
        | scheme                | greengot                                                                                                                                    |
        | configuration         | Debug                                                                                                                                       |
        | export_options        |                                                                                                                                             |
        | export_xcargs         | OTHER_CODE_SIGN_FLAGS="--keychain /var/folders/97/73j93h690g9gdn54bh_zskm40000gn/T/turtle-v2-7e963dc1-4490-447d-a422-5fbf97c2632f.keychain" |
        | disable_xcpretty      | true                                                                                                                                        |
        | buildlog_path         | /Users/expo/workingdir/logs                                                                                                                 |
        | output_directory      | ./build                                                                                                                                     |
        +-----------------------+---------------------------------------------------------------------------------------------------------------------------------------------+
        Resolving Swift Package Manager dependencies...
        $ xcodebuild -resolvePackageDependencies -workspace ./greengot.xcworkspace -scheme greengot -configuration Debug
        ▸ Command line invocation:
        ▸     /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -resolvePackageDependencies -workspace ./greengot.xcworkspace -scheme greengot -configuration Debug
        ▸ resolved source packages:
        $ xcodebuild -showBuildSettings -workspace ./greengot.xcworkspace -scheme greengot -configuration Debug
        Command timed out after 3 seconds on try 1 of 4, trying again with a 6 second timeout...
        [stderr] `<PBXResourcesBuildPhase UUID=`13B07F8E1A680F5B00A75B9A`>` attempted to initialize an object with an unknown UUID. `A180AD5A7D66431C803F218B` for attribute: `files`. This can be the result of a merge and the unknown UUID is being discarded.
        Detected provisioning profile mapping: {:"com.green-got"=>"296dd604-7da4-4693-8537-ce89ee1ff259"}
        [stderr] `<PBXResourcesBuildPhase UUID=`13B07F8E1A680F5B00A75B9A`>` attempted to initialize an object with an unknown UUID. `A180AD5A7D66431C803F218B` for attribute: `files`. This can be the result of a merge and the unknown UUID is being discarded.
        +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------+
        |                                                                                     Summary for gym 2.178.0                                                                                     |
        +---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------+
        | workspace                                         | ./greengot.xcworkspace                                                                                                                      |
        | scheme                                            | greengot                                                                                                                                    |
        | clean                                             | false                                                                                                                                       |
        | output_directory                                  | ./build                                                                                                                                     |
        | output_name                                       | green-got                                                                                                                                   |
        | configuration                                     | Debug                                                                                                                                       |
        | silent                                            | false                                                                                                                                       |
        | skip_package_ipa                                  | false                                                                                                                                       |
        | skip_package_pkg                                  | false                                                                                                                                       |
        | export_options.method                             | ad-hoc                                                                                                                                      |
        | export_options.provisioningProfiles.com.green-got | 296dd604-7da4-4693-8537-ce89ee1ff259                                                                                                        |
        | export_xcargs                                     | OTHER_CODE_SIGN_FLAGS="--keychain /var/folders/97/73j93h690g9gdn54bh_zskm40000gn/T/turtle-v2-7e963dc1-4490-447d-a422-5fbf97c2632f.keychain" |
        | build_path                                        | /Users/expo/Library/Developer/Xcode/Archives/2021-08-16                                                                                     |
        | result_bundle                                     | false                                                                                                                                       |
        | buildlog_path                                     | /Users/expo/workingdir/logs                                                                                                                 |
        | 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 ./greengot.xcworkspace -scheme greengot -configuration Debug -destination 'generic/platform=iOS' -archivePath /Users/expo/Library/Developer/Xcode/Archives/2021-08-16/green-got\ 2021-08-16\ 01.25.16.xcarchive archive | tee /Users/expo/workingdir/logs/green-got-greengot.log > /dev/null
        › Executing @unimodules/core Pods/UMCore » [CP] Copy XCFrameworks
        › Preparing react-native Pods/React-Core-AccessibilityResources » ResourceBundle-AccessibilityResources-React-Core-Info.plist
       ...
        › Executing lottie-react-native Pods/lottie-react-native » Copy generated compatibility header
        › Packaging react-native-reanimated Pods/RNReanimated » libRNReanimated.a
        › Compiling Pods/Pods-greengot » Pods-greengot-dummy.m
        › Packaging Pods/Pods-greengot » libPods-greengot.a
            Provisioning profile "*[expo] com.green-got AdHoc 1629101826578" for "greengot" contains entitlements that aren't in the entitlements file: com.apple.developer.associated-domains.mdm-managed. To use these entitlements, add them to your entitlements file. Otherwise, remove unused entitlements from your provisioning profile. (in target 'greengot' from project 'greengot')
        › Executing greengot » [CP] Check Pods Manifest.lock
        › Executing greengot » Start Packager
        › Compiling greengot » noop-file.swift
        › Compiling greengot » green-got_vers.c
        › Compiling greengot » main.m
        › Compiling greengot » AppDelegate.m
            pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
        › Linking   greengot » green-got
        › Copying ios/greengot/Supporting/Expo.plist ➜ Expo.plist
        › Compiling greengot » SplashScreen.storyboard
        › Compiling greengot » LaunchScreen.xib
        › Preparing greengot » Info.plist
        › Executing greengot » Bundle React Native code and images
            the transform cache was reset.
        
        ❌ Metro encountered an error:
        Cannot read property 'transformFile' of undefined
        › Generating debug greengot » green-got.app.dSYM
        ⚠️  Pods/boost-for-react-native: iOS@8.0 deployment version mismatch, expected >= 9.0 <= 14.4.99
        ▸ ** ARCHIVE FAILED **
        ▸ The following build commands failed:
        ▸ 	PhaseScriptExecution Bundle\ React\ Native\ code\ and\ images /Users/expo/Library/Developer/Xcode/DerivedData/greengot-djveyphpwyosjubjkipdmcftptmp/Build/Intermediates.noindex/ArchiveIntermediates/greengot/IntermediateBuildFilesPath/greengot.build/Debug-iphoneos/greengot.build/Script-00DD1BFF1BD5951E006B06BC.sh
        ▸ (1 failure)
        ** ARCHIVE FAILED **
        The following build commands failed:
        	PhaseScriptExecution Bundle\ React\ Native\ code\ and\ images /Users/expo/Library/Developer/Xcode/DerivedData/greengot-djveyphpwyosjubjkipdmcftptmp/Build/Intermediates.noindex/ArchiveIntermediates/greengot/IntermediateBuildFilesPath/greengot.build/Debug-iphoneos/greengot.build/Script-00DD1BFF1BD5951E006B06BC.sh
        (1 failure)
        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.

On in my ios log I have this error:

      Welcome to Metro!
                  Fast - Scalable - Integrated
    Failed to construct transformer:  TypeError: Transformer is not a constructor
        at getTransformCacheKey (/Users/expo/workingdir/build/node_modules/metro/src/DeltaBundler/Transformer/getTransformCacheKey.js:33:31)
        at new Transformer (/Users/expo/workingdir/build/node_modules/metro/src/DeltaBundler/Transformer.js:147:28)
        at /Users/expo/workingdir/build/node_modules/metro/src/Bundler.js:54:29
        at runMicrotasks (<anonymous>)
        at processTicksAndRejections (internal/process/task_queues.js:93:5)
    Error: @build-script-error-begin
    Error loading assets JSON from Metro. Ensure you've followed all expo-updates installation steps correctly. Cannot read property 'transformFile' of undefined
    @build-script-error-end
        at /Users/expo/workingdir/build/node_modules/expo-updates/scripts/createManifest.js:39:11
        at runMicrotasks (<anonymous>)
        at processTicksAndRejections (internal/process/task_queues.js:93:5)
    Command PhaseScriptExecution failed with a nonzero exit code
    GenerateDSYMFile /Users/expo/Library/Developer/Xcode/DerivedData/greengot-djveyphpwyosjubjkipdmcftptmp/Build/Intermediates.noindex/ArchiveIntermediates/greengot/BuildProductsPath/Debug-iphoneos/green-got.app.dSYM /Users/expo/Library/Developer/Xcode/DerivedData/greengot-djveyphpwyosjubjkipdmcftptmp/Build/Intermediates.noindex/ArchiveIntermediates/greengot/InstallationBuildProductsLocation/Applications/green-got.app/green-got (in target 'greengot' from project 'greengot')

Ps: I don’t have expo-updates on my dependencies

If it can help … here is my app.json :

{
  "expo": {
    "name": "green-got",
    "slug": "green-got",
    "version": "0.0.1",
    "privacy": "unlisted",
    "orientation": "portrait",
    "owner": "greengot",
    "sdkVersion": "41.0.0",
    "icon": "./assets/images/app-icon.png",
    "splash": {
      "image": "./assets/images/splash2.png",
      "resizeMode": "cover",
      "backgroundColor": "#ffffff"
    },
    "assetBundlePatterns": ["assets/**/*"],
    "ios": {
      "bundleIdentifier": "com.green-got",
      "buildNumber": "1.0.0",
      "supportsTablet": true,
      "infoPlist": {
        "NSAppTransportSecurity": {
          "NSExceptionDomains": {
            "192.168.1.76": {
              "NSTemporaryExceptionAllowsInsecureHTTPLoads": true
            },
            "'https://green-got.com": {
              "NSTemporaryExceptionAllowsInsecureHTTPLoads": true
            }
          }
        },
        "CFBundleAllowMixedLocalizations": true
      },
      "backgroundColor": "#FFF"
    },
    "android": {
      "package": "com.green_got.preview",
      "versionCode": 1,
      "adaptiveIcon": {
        "foregroundImage": "./assets/images/adaptive-icon.png",
        "backgroundColor": "#FFFFFF"
      }
    },
    "web": {
      "favicon": "./assets/images/favicon.png",
      "build": {
        "babel": {
          "include": ["./shared"]
        }
      }
    },
    "description": ""
  }
}

Ps2 : I’m on a mac M1

Do you understand this error and haw can I fix it?

can you share a link to your build page? also, the contents of metro.config.js

sure , here is my build page : Build Details — 3c9076a3-1b49-4753-89ea-ea1f8c2d78a9 — @greengot/green-got — Expo

and my metro.config.js :

const { getDefaultConfig } = require("@expo/metro-config");

const defaultConfig = getDefaultConfig(__dirname);

module.exports = defaultConfig;

Let me know if you need anything else :wink:

oh i see. you are using an invalid react version for sdk 41. you need to use the version that is supported by sdk 41: exactly 16.13.1. each version of expo and react-native work with exactly one version of react.

also, what version is your @expo/metro-config package?

it’s hard to know exactly what is going on here but it seems like something is incompatible with your metro config version and the version of metro in your project. you should try updating to sdk 42 also, eas build works much better on sdk 42 projects – sdk 41 was our first pass at eas build managed app support, and it improved a lot between releases.

Thx @notbrent it’s already a very good lead !
My @expo/metro-config version is : "^0.1.81"
But I still need to install a version of @metro from sdk 41?

If I create a new expo SDK 42 app I get the following dependencies by default:

{
  "expo": "~42.0.1",
  "expo-status-bar": "~1.0.4",
  "react": "16.13.1",
  "react-dom": "16.13.1",
  "react-native": "https://github.com/expo/react-native/archive/sdk-42.0.0.tar.gz",
  "react-native-web": "~0.13.12"
}

The actual versions are as follows:

=> Found "expo@42.0.3"
=> Found "expo-status-bar@1.0.4"
=> Found "react@16.13.1"
=> Found "react-native-web@0.13.18"

I didn’t look up the version of “react-native”, because it’s pointing at the Expo SDK 42 tar file on github.
I used yarn why expo etc. to find these. Maybe there’s a better way.

If you expo upgrade to SDK 42, then compare the versions of these dependencies with yours.
Then for any extra dependencies you probably want to run expo install xxx on each one. That should install the correct version if possible.

i don’t think the metro config version is related actually, because the react-native version remained the same between sdk 41 and 42. i’d be curious to see your full package.json

also, you can debug this locally with expo run:ios. you can cleanup any generated files after you’re done with fyi/prebuild-cleanup.md at master · expo/fyi · GitHub

1 Like

Thx @notbrent & @wodin after updating to sdk42 and had the right lottie-ios version the build was successful !

The expo run:ios is a command that helps a lot ^^ now I’m stuck with a splashScreen crash but it’s another thing :wink: