nx: [EXPO][EAS][iOS]["useFrameworks": "static"] Build fails to resolve from react-native bridging headers

Current Behavior

Local eas iOS build fails to resolve react/bridging/CallbackWrapper.h and react/bridging/LongLivedObject.h from the react-native bridging headers. There’s no such issue in a project built outside of nx with npx create-expo-app my-app

Expected Behavior

Able to build an iOS app using "useFrameworks": "static"

Github Repo

No response

Steps to Reproduce

  1. Create an empty workspace with either npm or yarn
  2. Add an expo app
  3. Add a library like React Native Firebase that uses "useFrameworks": "static"
  4. Prebuild the app npm exec -- expo prebuild --clean
  5. Build the iOS app npm exec -- eas build --profile=development --platform=ios --local

Nx Report

Node : 16.18.1
   OS   : darwin arm64
   npm  : 9.1.3
   
   nx : 15.4.1
   @nrwl/angular : Not Found
   @nrwl/cypress : 15.4.1
   @nrwl/detox : 15.4.1
   @nrwl/devkit : 15.4.1
   @nrwl/esbuild : Not Found
   @nrwl/eslint-plugin-nx : 15.4.1
   @nrwl/expo : 15.4.1
   @nrwl/express : Not Found
   @nrwl/jest : 15.4.1
   @nrwl/js : 15.4.1
   @nrwl/linter : 15.4.1
   @nrwl/nest : Not Found
   @nrwl/next : Not Found
   @nrwl/node : Not Found
   @nrwl/nx-cloud : Not Found
   @nrwl/nx-plugin : Not Found
   @nrwl/react : 15.4.1
   @nrwl/react-native : Not Found
   @nrwl/rollup : 15.4.1
   @nrwl/schematics : Not Found
   @nrwl/storybook : Not Found
   @nrwl/web : 15.4.1
   @nrwl/webpack : 15.4.1
   @nrwl/workspace : 15.4.1
   @nrwl/vite : 15.4.1
   typescript : 4.8.4
   ---------------------------------------
   Local workspace plugins:
   ---------------------------------------
   Community plugins:

app.json

{
  "expo": {
    "name": "Native App",
    "slug": "native-app",
    "version": "1.0.0",
    "jsEngine": "hermes",
    "orientation": "portrait",
    "icon": "./assets/icon.png",
    "splash": {
      "image": "./assets/splash.png",
      "resizeMode": "contain",
      "backgroundColor": "#ffffff"
    },
    "updates": {
      "fallbackToCacheTimeout": 0
    },
    "assetBundlePatterns": ["**/*"],
    "ios": {
      "supportsTablet": true,
      "bundleIdentifier": "com.native.app",
      "entitlements": {
        "com.apple.developer.devicecheck.appattest-environment": "development",
        "com.apple.developer.networking.wifi-info": true
      },
      "googleServicesFile": "./GoogleService-Info.plist"
    },
    "android": {
      "adaptiveIcon": {
        "foregroundImage": "./assets/adaptive-icon.png",
        "backgroundColor": "#FFFFFF"
      },
      "package": "com.native.app",
      "googleServicesFile": "./google-services.json"
    },
    "web": {
      "favicon": "./assets/favicon.png"
    },
    "extra": {
      "eas": {
        "projectId": ""
      }
    },
    "plugins": [
      "@react-native-firebase/app",
      "@react-native-firebase/perf",
      "@react-native-firebase/crashlytics",
      [
        "expo-build-properties",
        {
          "ios": {
            "useFrameworks": "static"
          }
        }
      ]
    ]
  }
}

Podfile

require File.join(File.dirname(`node --print "require.resolve('expo/package.json')"`), "scripts/autolinking")
require File.join(File.dirname(`node --print "require.resolve('react-native/package.json')"`), "scripts/react_native_pods")
require File.join(File.dirname(`node --print "require.resolve('@react-native-community/cli-platform-ios/package.json')"`), "native_modules")

require 'json'
podfile_properties = JSON.parse(File.read(File.join(__dir__, 'Podfile.properties.json'))) rescue {}

platform :ios, podfile_properties['ios.deploymentTarget'] || '13.0'
install! 'cocoapods',
  :deterministic_uuids => false

target 'RnfbApp' do
  use_expo_modules!
  config = use_native_modules!

  use_frameworks! :linkage => podfile_properties['ios.useFrameworks'].to_sym if podfile_properties['ios.useFrameworks']

  # Flags change depending on the env values.
  flags = get_default_flags()

  use_react_native!(
    :path => config[:reactNativePath],
    :hermes_enabled => podfile_properties['expo.jsEngine'] == 'hermes',
    :fabric_enabled => flags[:fabric_enabled],
    # An absolute path to your application root.
    :app_path => "#{Pod::Config.instance.installation_root}/..",
    #
    # Uncomment to opt-in to using Flipper
    # Note that if you have use_frameworks! enabled, Flipper will not work
    # :flipper_configuration => !ENV['CI'] ? FlipperConfiguration.enabled : FlipperConfiguration.disabled,
  )

  post_install do |installer|
    react_native_post_install(
      installer,
      # Set `mac_catalyst_enabled` to `true` in order to apply patches
      # necessary for Mac Catalyst builds
      :mac_catalyst_enabled => false
    )
    __apply_Xcode_12_5_M1_post_install_workaround(installer)

    # This is necessary for Xcode 14, because it signs resource bundles by default
    # when building for devices.
    installer.target_installation_results.pod_target_installation_results
      .each do |pod_name, target_installation_result|
      target_installation_result.resource_bundle_targets.each do |resource_bundle_target|
        resource_bundle_target.build_configurations.each do |config|
          config.build_settings['CODE_SIGNING_ALLOWED'] = 'NO'
        end
      end
    end
  end

  post_integrate do |installer|
    begin
      expo_patch_react_imports!(installer)
    rescue => e
      Pod::UI.warn e
    end
  end
end

Failure Logs

[RUN_FASTLANE] › Creating  cxxreact.framework
[RUN_FASTLANE] › Copying   react-native ios/build/Build/Products/Debug-iphonesimulator/ReactCommon/ReactCommon.framework/Headers/TurboModuleUtils.h ➜ ../../../../../../var/folders/29/hkk177js0mn_fr5d_bvwmyjr0000gn/T/eas-build-local-nodejs/5c1e7387-965d-4a78-a585-1d4fa87c2907/build/node_modules/react-native/ReactCommon/react/nativemodule/core/ReactCommon/TurboModuleUtils.h
[RUN_FASTLANE] › Copying   react-native ios/build/Build/Products/Debug-iphonesimulator/ReactCommon/ReactCommon.framework/Headers/TurboModulePerfLogger.h ➜ ../../../../../../var/folders/29/hkk177js0mn_fr5d_bvwmyjr0000gn/T/eas-build-local-nodejs/5c1e7387-965d-4a78-a585-1d4fa87c2907/build/node_modules/react-native/ReactCommon/react/nativemodule/core/ReactCommon/TurboModulePerfLogger.h
[RUN_FASTLANE] › Copying   react-native ios/build/Build/Products/Debug-iphonesimulator/ReactCommon/ReactCommon.framework/Headers/TurboModuleBinding.h ➜ ../../../../../../var/folders/29/hkk177js0mn_fr5d_bvwmyjr0000gn/T/eas-build-local-nodejs/5c1e7387-965d-4a78-a585-1d4fa87c2907/build/node_modules/react-native/ReactCommon/react/nativemodule/core/ReactCommon/TurboModuleBinding.h
[RUN_FASTLANE] › Copying   react-native ios/build/Build/Products/Debug-iphonesimulator/ReactCommon/ReactCommon.framework/Headers/TurboModule.h ➜ ../../../../../../var/folders/29/hkk177js0mn_fr5d_bvwmyjr0000gn/T/eas-build-local-nodejs/5c1e7387-965d-4a78-a585-1d4fa87c2907/build/node_modules/react-native/ReactCommon/react/nativemodule/core/ReactCommon/TurboModule.h
[RUN_FASTLANE] › Copying   react-native ios/build/Build/Products/Debug-iphonesimulator/ReactCommon/ReactCommon.framework/Headers/TurboCxxModule.h ➜ ../../../../../../var/folders/29/hkk177js0mn_fr5d_bvwmyjr0000gn/T/eas-build-local-nodejs/5c1e7387-965d-4a78-a585-1d4fa87c2907/build/node_modules/react-native/ReactCommon/react/nativemodule/core/ReactCommon/TurboCxxModule.h
[RUN_FASTLANE] › Copying   react-native ios/build/Build/Products/Debug-iphonesimulator/ReactCommon/ReactCommon.framework/Headers/ReactCommon-umbrella.h ➜ ios/Pods/Target/ Support/ Files/ReactCommon/ReactCommon-umbrella.h
[RUN_FASTLANE] › Copying   react-native ios/build/Build/Products/Debug-iphonesimulator/ReactCommon/ReactCommon.framework/Headers/RCTTurboModuleManager.h ➜ ../../../../../../var/folders/29/hkk177js0mn_fr5d_bvwmyjr0000gn/T/eas-build-local-nodejs/5c1e7387-965d-4a78-a585-1d4fa87c2907/build/node_modules/react-native/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModuleManager.h
[RUN_FASTLANE] › Copying   react-native ios/build/Build/Products/Debug-iphonesimulator/ReactCommon/ReactCommon.framework/Headers/RCTTurboModule.h ➜ ../../../../../../var/folders/29/hkk177js0mn_fr5d_bvwmyjr0000gn/T/eas-build-local-nodejs/5c1e7387-965d-4a78-a585-1d4fa87c2907/build/node_modules/react-native/ReactCommon/react/nativemodule/core/platform/ios/RCTTurboModule.h
[RUN_FASTLANE] › Copying   react-native ios/build/Build/Products/Debug-iphonesimulator/ReactCommon/ReactCommon.framework/Headers/RCTBlockGuard.h ➜ ../../../../../../var/folders/29/hkk177js0mn_fr5d_bvwmyjr0000gn/T/eas-build-local-nodejs/5c1e7387-965d-4a78-a585-1d4fa87c2907/build/node_modules/react-native/ReactCommon/react/nativemodule/core/platform/ios/RCTBlockGuard.h
[RUN_FASTLANE] › Copying   react-native ios/build/Build/Products/Debug-iphonesimulator/ReactCommon/ReactCommon.framework/Headers/LongLivedObject.h ➜ ../../../../../../var/folders/29/hkk177js0mn_fr5d_bvwmyjr0000gn/T/eas-build-local-nodejs/5c1e7387-965d-4a78-a585-1d4fa87c2907/build/node_modules/react-native/ReactCommon/react/nativemodule/core/ReactCommon/LongLivedObject.h
[RUN_FASTLANE] › Compiling react-native Pods/ReactCommon » TurboModuleUtils.cpp
[RUN_FASTLANE] 
❌  (../../node_modules/react-native/ReactCommon/react/nativemodule/core/ReactCommon/TurboModuleUtils.h:16:10)

  14 | 
  15 | #include <ReactCommon/CallInvoker.h>
> 16 | #include <react/bridging/CallbackWrapper.h>
     |          ^ 'react/bridging/CallbackWrapper.h' file not found
  17 | #include <react/bridging/LongLivedObject.h>
  18 | 
  19 | namespace facebook {

[RUN_FASTLANE] › Compiling react-native Pods/ReactCommon » TurboModulePerfLogger.cpp
[RUN_FASTLANE] › Compiling react-native Pods/ReactCommon » TurboModuleBinding.cpp
[RUN_FASTLANE] 
❌  (../../node_modules/react-native/ReactCommon/react/nativemodule/core/ReactCommon/LongLivedObject.h:11:10)

   9 | 
  10 | // This header is left here for compatibility reasons.
> 11 | #include <react/bridging/LongLivedObject.h>
     |          ^ 'react/bridging/LongLivedObject.h' file not found
  12 | 

[RUN_FASTLANE] › Compiling react-native Pods/ReactCommon » TurboModule.cpp
[RUN_FASTLANE] › Compiling react-native Pods/ReactCommon » TurboCxxModule.cpp
[RUN_FASTLANE] › Compiling react-native Pods/ReactCommon » ReactCommon_vers.c
[RUN_FASTLANE] ▸ ** BUILD FAILED **
[RUN_FASTLANE] ▸ The following build commands failed:
[RUN_FASTLANE] ▸        CompileC /var/folders/29/hkk177js0mn_fr5d_bvwmyjr0000gn/T/eas-build-local-nodejs/5c1e7387-965d-4a78-a585-1d4fa87c2907/build/apps/native-app/ios/build/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/ReactCommon.build/Objects-normal/x86_64/TurboModuleUtils.o /var/folders/29/hkk177js0mn_fr5d_bvwmyjr0000gn/T/eas-build-local-nodejs/5c1e7387-965d-4a78-a585-1d4fa87c2907/build/node_modules/react-native/ReactCommon/react/nativemodule/core/ReactCommon/TurboModuleUtils.cpp normal x86_64 c++ com.apple.compilers.llvm.clang.1_0.compiler (in target 'ReactCommon' from project 'Pods')
[RUN_FASTLANE] ▸ (1 failure)
[RUN_FASTLANE] › Compiling react-native Pods/ReactCommon » ReactCommon-dummy.m
[RUN_FASTLANE] ** BUILD FAILED **
[RUN_FASTLANE] 
[RUN_FASTLANE] 
[RUN_FASTLANE] The following build commands failed:
[RUN_FASTLANE]  CompileC /var/folders/29/hkk177js0mn_fr5d_bvwmyjr0000gn/T/eas-build-local-nodejs/5c1e7387-965d-4a78-a585-1d4fa87c2907/build/apps/native-app/ios/build/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/ReactCommon.build/Objects-normal/x86_64/TurboModuleUtils.o /var/folders/29/hkk177js0mn_fr5d_bvwmyjr0000gn/T/eas-build-local-nodejs/5c1e7387-965d-4a78-a585-1d4fa87c2907/build/node_modules/react-native/ReactCommon/react/nativemodule/core/ReactCommon/TurboModuleUtils.cpp normal x86_64 c++ com.apple.compilers.llvm.clang.1_0.compiler (in target 'ReactCommon' from project 'Pods')
[RUN_FASTLANE] (1 failure)
[RUN_FASTLANE] Exit status: 65

Additional Information

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 3
  • Comments: 28 (9 by maintainers)

Most upvoted comments

@evelant what about Yarn users? Can I use the patch with Yarn?

Thanks @ste7en for the support. I have managed to get the iOS build working manually via Xcode with the manual fix.

when hermese is enabled, I had to use_frameworks! :linkage => :static

when hermese is disabled use_frameworks! in both case ` __apply_Xcode_12_5_M1_post_install_workaround(installer)

installer.pods_project.targets.each do |target|
  target.build_configurations.each do |config|
    config.build_settings["HEADER_SEARCH_PATHS"] ||= "$(inherited) "
    config.build_settings["HEADER_SEARCH_PATHS"] << '"$(PODS_TARGET_SRCROOT)" '
    config.build_settings['HEADER_SEARCH_PATHS'] << '"$(PODS_ROOT)/Headers/Private/React-bridging" '
  end
end

nx_post_install(installer)

my package versions are “dependencies”: { “@react-native-firebase/app”: “^16.7.0”, “@react-native-firebase/crashlytics”: “^16.7.0”, “expo”: “^47.0.13”, “expo-constants”: “^14.0.2”, “patch-package”: “^6.5.1”, “postinstall-postinstall”: “^2.1.0”, “react”: “18.1.0”, “react-dom”: “18.1.0”, “react-native”: “0.70.6”, “tslib”: “^2.3.0” }

`

@RohanWeli you can use this patch on react-native 0.70.6: react-native@0.70.6.patch

Just run patch -p1 < react-native@0.70.6.patch inside your node_modules/react-native directory (or temporary directory) after you’ve started the patching process through your package manager (I guess you’re going to use patch-package for Yarn 1, yarn patch for Yarn ≥2).

Otherwise, if you’re following the manual fix, choose React-bridging target from your Pods project, go to Build Phases tab and, from the Copy xxx... phase, select Absolute Path as Destination. The, add $(PODS_ROOT)/Headers/Private/React-bridging to the main project header search paths and the project will finally build. But the next time you’re going to pod install your project this must be re-applied.

@ste7en This is fixed in react-native 0.71. Since we can’t use that with expo yet I created a patch that backports the fixes so that pnpm users can compile with use_frameworks!.

Patch: react-native@0.70.6.patch

You can apply it with pnpm’s patchedDependencies. Put the patch in a patches folder at the root of your project then add to your root package.json

"pnpm": {
    "patchedDependencies": {
        "react-native@0.70.6": "patches/react-native@0.70.6.patch"
    }
}

upon pnpm install it will patch react-native to fix the ios build issues.