nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.7k stars 2.37k forks source link

Build React Native iOS app fails when use_frameworks! is enabled in RN 0.72.6 #20692

Open nileshzype opened 11 months ago

nileshzype commented 11 months ago

Current Behavior

Trying to run, but getting below error

image

This happens also when I create a clean new react native app using @nrwl/react-native generator and I add to the Podfile:

image

Expected Behavior

I expect the build to succeed with use_frameworks. In my project use_frameworks is required to run react-native-firebase.

GitHub Repo

No response

Steps to Reproduce

  1. Create an NX workspace
  2. Generate a React Native app
  3. Add "use_frameworks! :linkage => :static" in pod file
  4. Build the app

Nx Report

Node   : 20.3.1
   OS     : darwin-x64
   npm    : 9.6.7

   nx (global)        : 16.5.2
   nx                 : 17.2.0
   @nx/js             : 17.2.0
   @nx/jest           : 17.2.0
   @nx/linter         : 17.2.0
   @nx/eslint         : 17.2.0
   @nx/workspace      : 17.2.0
   @nx/cypress        : 17.2.0
   @nx/detox          : 17.2.0
   @nx/devkit         : 17.2.0
   @nx/eslint-plugin  : 17.2.0
   @nx/expo           : 17.2.0
   @nx/react          : 17.2.0
   @nx/react-native   : 17.2.0
   @nrwl/tao          : 17.2.0
   @nx/web            : 17.2.0
   @nx/webpack        : 17.2.0
   nx-cloud           : 16.5.2
   typescript         : 5.1.6

Failure Logs

No response

Package Manager Version

No response

Operating System

Additional Information

No response

malikkhoja commented 11 months ago

We are facing similar issues. It works on Android and Web but on IOS it gives errors. @nileshzype @xiongemi Any solution to fix this issue?

arishZype commented 11 months ago

Yes, I am facing the same issue. Any solutions yet?

nileshzype commented 10 months ago

@jaysoo & @xiongemi Can you guys help on this.

malikkhoja commented 10 months ago

We are stuck because of this issue and cannot update NX and React Native in our production apps. @jaysoo @xiongemi Can you please help me?

xiongemi commented 9 months ago

it seems fine for me when i try to 17.2.6

i change the pod file to:

# Resolve react_native_pods.rb with node to allow for hoisting
require Pod::Executable.execute_command('node', ['-p',
  'require.resolve(
    "react-native/scripts/react_native_pods.rb",
    {paths: [process.argv[1]]},
  )', __dir__]).strip

platform :ios, min_ios_version_supported
prepare_react_native_project!

# If you are using a `react-native-flipper` your iOS build will fail when `NO_FLIPPER=1` is set.
# because `react-native-flipper` depends on (FlipperKit,...) that will be excluded
#
# To fix this you can also exclude `react-native-flipper` using a `react-native.config.js`
# ```js
# module.exports = {
#   dependencies: {
#     ...(process.env.NO_FLIPPER ? { 'react-native-flipper': { platforms: { ios: null } } } : {}),
# ```
flipper_config = ENV['NO_FLIPPER'] == "1" ? FlipperConfiguration.disabled : FlipperConfiguration.enabled

linkage = ENV['USE_FRAMEWORKS']
if linkage != nil
  Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green
  use_frameworks! :linkage => :static
end

target 'Mobile' do
  config = use_native_modules!

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

  use_react_native!(
    :path => config[:reactNativePath],
    # Hermes is now enabled by default. Disable by setting this flag to false.
    :hermes_enabled => flags[:hermes_enabled],
    :fabric_enabled => flags[:fabric_enabled],
    # Enables Flipper.
    #
    # Note that if you have use_frameworks! enabled, Flipper will not work and
    # you should disable the next line.
    :flipper_configuration => flipper_config,
    # An absolute path to your application root.
    :app_path => "#{Pod::Config.instance.installation_root}/.."
  )

  target 'MobileTests' do
    inherit! :complete
    # Pods for testing
  end

  post_install do |installer|
    # https://github.com/facebook/react-native/blob/main/packages/react-native/scripts/react_native_pods.rb#L197-L202
    react_native_post_install(
      installer,
      config[:reactNativePath],
      :mac_catalyst_enabled => false
    )
    __apply_Xcode_12_5_M1_post_install_workaround(installer)
  end
end

then run the nx pod-install mobile and nx start mobile and able to build the app in XCode. what does your podfile look like? do you have a repo?

malikzype commented 9 months ago

@xiongemi Tried with the same Pod File but still getting the same error node_modules/react-native/ReactCommon/react/utils/RunLoopObserver.cpp:10:10: fatal error: 'react/debug/react_native_assert.h' file not found

include <react/debug/react_native_assert.h>

Can you help further?

xiongemi commented 9 months ago

@malikkhoja what version of react native do you have? i think it is a react native issue: https://github.com/facebook/react-native/issues/38283 https://github.com/facebook/react-native/issues/38140#issuecomment-1614755738

from the thread, are you using react-native-image-picker or pnpm?

malikzype commented 9 months ago

@xiongemi it works on RN 0.72.4 but it doesn't on RN 0.72.6 with useFrameworks.

Also, we are not using react-native-image-picker or pnpm.

github-actions[bot] commented 3 months ago

This issue has been automatically marked as stale because it hasn't had any activity for 6 months. Many things may have changed within this time. The issue may have already been fixed or it may not be relevant anymore. If at this point, this is still an issue, please respond with updated information. It will be closed in 21 days if no further activity occurs. Thanks for being a part of the Nx community! 🙏

airowe commented 3 months ago

I'm seeing this problem as well trying to update react-native-firebase. @xiongemi was there ever any concrete resolution to this issue?