react-native icon indicating copy to clipboard operation
react-native copied to clipboard

New Arch 0.72.1 issue with use_frameworks! - file not found.How to fix?

Open billnbell opened this issue 11 months ago • 18 comments

Description

Getting error on RCTImageComponentView.mm - node_modules/react-native/React/Fabric/Mounting/ComponentViews/Image/RCTImageComponentView.mm

#import <react/renderer/imagemanager/RCTImagePrimitivesConversions.h>
▸ Compiling RCTImageComponentView.mm

❌  /Users/bill_1/theclub/TheClub/node_modules/react-native/React/Fabric/Mounting/ComponentViews/Image/RCTImageComponentView.mm:19:9: 'react/renderer/imagemanager/RCTImagePrimitivesConversions.h' file not found

How do I fix this ?

React Native Version

0.72.1

Output of npx react-native info

info Fetching system and libraries information...
System:
  OS: macOS 13.4.1
  CPU: (12) arm64 Apple M2 Max
  Memory: 785.88 MB / 32.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 18.16.0
    path: /opt/homebrew/opt/node@18/bin/node
  Yarn:
    version: 1.22.19
    path: /opt/homebrew/bin/yarn
  npm:
    version: 9.5.1
    path: /opt/homebrew/opt/node@18/bin/npm
  Watchman:
    version: 2023.05.22.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.12.1
    path: /usr/local/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 22.4
      - iOS 16.4
      - macOS 13.3
      - tvOS 16.4
      - watchOS 9.4
  Android SDK:
    API Levels:
      - "30"
      - "33"
    Build Tools:
      - 30.0.3
      - 33.0.0
      - 33.0.2
    System Images:
      - android-33 | Google APIs ARM 64 v8a
      - android-33 | Google Play ARM 64 v8a
    Android NDK: Not Found
IDEs:
  Android Studio: 2022.2 AI-222.4459.24.2221.10121639
  Xcode:
    version: 14.3.1/14E300c
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 11.0.19
    path: /usr/bin/javac
  Ruby:
    version: 2.6.10
    path: /usr/bin/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.72.1
    wanted: ^0.72.1
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: true

Steps to reproduce

See above

Snack, code example, screenshot, or link to a repository

See above

billnbell avatar Jul 05 '23 01:07 billnbell

:warning: Issue is a Question
:information_source: We are using GitHub issues exclusively to track bugs in React Native. GitHub may not be the ideal place to ask a question, but you can try asking over on Stack Overflow, or on Reactiflux.

github-actions[bot] avatar Jul 05 '23 12:07 github-actions[bot]

It is not a question. I am getting an error when building with

cd ios && USE_FABRIC=1 RCT_NEW_ARCH_ENABLED=1 pod install
yarn ios

This is the error I get when using use_frameworks! :linkage => :static

This is pretty insulting as well, since I have been fixing tons of packages to work with use_frameworks.

The Discussion link - https://github.com/reactwg/react-native-new-architecture/discussions/115 does not allow me to report back (since someone turned off all comments there) on you guide to get use_frameworks to work with react-native. Asking me to use Stack Overflow is not useful, considering use_frameworks and RCT_NEW_ARCH_ENABLED=1 is quite new!

Compiling node_modules/react-native/React/Fabric/Mounting/ComponentViews/Image/RCTImageComponentView.mm is part of React Native proper and I am unsure which Podspec controls that. I am looking around, and I am sure I can fix the header once I can figure out where the PODSPEC is. There are several under Fabric.

billnbell avatar Jul 06 '23 04:07 billnbell

It is not a question. I am getting an error when building with

@billnbell I marked this as a question as you haven't filled the issue template. Specifically you haven't provided the output of npx react-native info neither a reproducer. Those are mandatory for issues to be considered.

Don't you mind editing your response and providing them? We can reopen it afterwards

cortinico avatar Jul 06 '23 07:07 cortinico

OK it is updated thanks.

billnbell avatar Jul 06 '23 07:07 billnbell

Hi @billnbell, can you share your Podfile and the list of dependencies? The problem is likely caused by one of your dependencies as we are building 0.72.1 in CI with static frameworks and it works.

As a side note, some recommendations. You should install those pods with:

NO_FLIPPER=1 RCT_NEW_ARCH_ENABLED=1 bundle exec pod install
  • Flipper is not compatible with use_frameworks!, so you need to disable it
  • RCT_NEW_ARCH_ENABLED=1 overrides USE_FABRIC=1 (setting fabric to 1 as well) so the two are redundant.
  • use_frameworks! :linkage => :static must happen before the call to use_react_native!.
  • your extra depdendencies (firebase, for example) must be declared after the call to use_react_native!.

cipolleschi avatar Jul 06 '23 12:07 cipolleschi

I have Flipper permanently turned off in Podfile.

Yeah I am using RCT_NEW_ARCH_ENABLED=1.

The issues in a ton of rpm packages is Reat-ImageManager, React-utils and React-debug not finding Headers. I am literally entering these into podspec files to fix them. I think we should add these into install_modules_dependencies(s)

    s.dependency "React-ImageManager"
    s.dependency "React-utils"
    s.dependency "React-debug"
    s.subspec "xxximagemanager" do |ss|
      ss.dependency "React-ImageManager"
      ss.source_files         = "react/renderer/imagemanager/**/*.{cpp,h}"
      ss.header_dir           = "react/renderer/imagemanager/"
      ss.pod_target_xcconfig  = { "HEADER_SEARCH_PATHS" => "\"${PODS_CONFIGURATION_BUILD_DIR}/React-ImageManager/React_ImageManager.framework/Headers\"" }
    end

    s.subspec "xxxdebug" do |ss|
      ss.dependency "ReactCommon"
      ss.dependency "React-debug"
      ss.source_files         = "react/debug/**/*.{cpp,h}"
      ss.header_dir           = "react/debug"
      ss.pod_target_xcconfig  = { "HEADER_SEARCH_PATHS" => "\"${PODS_CONFIGURATION_BUILD_DIR}/React-debug/React_debug.framework/Headers\"" }
    end

    s.subspec "xxxutils" do |ss|
      ss.dependency "ReactCommon"
      ss.dependency "React-utils"
      ss.source_files         = "react/utils/**/*.{cpp,h}"
      ss.header_dir           = "react/utils"
      ss.pod_target_xcconfig  = { "HEADER_SEARCH_PATHS" => "\"${PODS_CONFIGURATION_BUILD_DIR}/React-utils/React_utils.framework/Headers\"" }
    end

billnbell avatar Jul 07 '23 06:07 billnbell

My Podfile.

# Resolve react_native_pods.rb with node to allow for hoisting
$FirebaseSDKVersion = '10.11.0'

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

# Toggle this to true for the no-ad-tracking Analytics subspec. Useful at minimum for Kids category apps.
# See: https://firebase.google.com/support/release-notes/ios#analytics - requires firebase-ios-sdk 7.11.0+
$RNFirebaseAnalyticsWithoutAdIdSupport = true

platform :ios, '13.4'
# platform :ios, min_ios_version_supported
prepare_react_native_project!
inhibit_all_warnings!

# 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
flipper_config = FlipperConfiguration.disabled

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

target 'TheClub' do
  $static_library = []
  config = use_native_modules!

  use_frameworks! :linkage => :static
  # $RNFirebaseAsStaticFramework = true
  
  # React Native Maps dependencies
  rn_maps_path = '../node_modules/react-native-maps'
  pod 'react-native-google-maps', :path => rn_maps_path

  # 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.
    # Upcoming versions of React Native may rely on get_default_flags(), but
    # we make it explicit here to aid in the React Native upgrade process.
    :hermes_enabled => true,
    :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}/.."
  )

  $static_library += [
   'React',
   'RNBootSplash',
   'Google-Maps-iOS-Utils',
   'GoogleMaps',
   'react-native-maps',
   'react-native-google-maps',
   'react-native-app-auth',
   'React-hermes',
   'React-ImageManager',
   # 'react-native-pdf',
   'react-native-safe-area-context',
   'RNSafeAreaContext'
  ]

  pre_install do |installer|
      Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}
      installer.pod_targets.each do |pod|
        bt = pod.send(:build_type)
        if $static_library.include?(pod.name)
          puts "Overriding the build_type to static_library from static_framework for #{pod.name}"
          def pod.build_type;
            Pod::BuildType.static_library
          end
        end
      end
      installer.pod_targets.each do |pod|
        bt = pod.send(:build_type)
        puts "#{pod.name} (#{bt})"
        puts "  linkage: #{bt.send(:linkage)} packaging: #{bt.send(:packaging)}"
      end
  end

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

  target 'TheClubStage' do
    inherit! :complete
  end

  post_install do |installer|
    installer.pods_project.targets.each do |target|

#      if target.name == 'react-native-google-maps'
#        target.build_configurations.each do |config|
#          config.build_settings['CLANG_ENABLE_MODULES'] = 'No'
#        end
#      end
      target.build_configurations.each do |config|
        # config.build_settings['ENABLE_BITCODE'] = 'NO'
        config.build_settings['EXPANDED_CODE_SIGN_IDENTITY'] = ""
        config.build_settings['ONLY_ACTIVE_ARCH'] = 'NO'
        config.build_settings['CODE_SIGNING_REQUIRED'] = "NO"
        config.build_settings['CODE_SIGNING_ALLOWED'] = "NO"
        # next 2 for new arch
        # config.build_settings['ARCHS[sdk=iphonesimulator*]'] = "arm64"
        # config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "x86_64"
        config.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = "arm64"
        config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
      end
    end

    react_native_post_install(
      installer,
      config[:reactNativePath],
      :mac_catalyst_enabled => false
    )
    __apply_Xcode_12_5_M1_post_install_workaround(installer)
  end
end

billnbell avatar Jul 07 '23 06:07 billnbell

Hi @billnbell, thanks for investigating the issue. Helps like this are very precious as we don't have the capacity to look into all the 3rd party libraries to see what they are using.

The issues in a ton of rpm packages is Reat-ImageManager, React-utils and React-debug not finding Headers. I am literally entering these into podspec files to fix them. I think we should add these into install_modules_dependencies(s)

This seems a very good suggestion. Could you open a PR with those changes?

Also, why do you need those subspecs? I don't like the idea of using them and they should not be needed. It should be enough to add the React-ImageManager, React-utils, and React-debug search paths to the global search path here.

cipolleschi avatar Jul 07 '23 08:07 cipolleschi

OK. I will try USE_FRAMEWORKS=static - I did not see that change to the documentation!!!

Docs missing... Or I cannot find them :)

Instead of use_frameworks! :linkage => :static just add USE_FRAMEWORKS=static before running pod install.

billnbell avatar Jul 07 '23 18:07 billnbell

The pods all need install_modules_dependencies(s) which is a change we need to communicate in the BLOG or something.

billnbell avatar Jul 07 '23 21:07 billnbell

Hi @billnbell, can you share your Podfile and the list of dependencies? The problem is likely caused by one of your dependencies as we are building 0.72.1 in CI with static frameworks and it works.

As a side note, some recommendations. You should install those pods with:

NO_FLIPPER=1 RCT_NEW_ARCH_ENABLED=1 bundle exec pod install
  • Flipper is not compatible with use_frameworks!, so you need to disable it
  • RCT_NEW_ARCH_ENABLED=1 overrides USE_FABRIC=1 (setting fabric to 1 as well) so the two are redundant.
  • use_frameworks! :linkage => :static must happen before the call to use_react_native!.
  • your extra depdendencies (firebase, for example) must be declared after the call to use_react_native!.

I would also say NO_FLIPPER=1 USE_FRAMEWORKS=static RCT_NEW_ARCH_ENABLED=1 pod install seems to be good or NO_FLIPPER=1 USE_FRAMEWORKS=static RCT_NEW_ARCH_ENABLED=1 bundle exec pod install

billnbell avatar Jul 07 '23 21:07 billnbell

https://github.com/facebook/react-native/pull/38247

billnbell avatar Jul 07 '23 21:07 billnbell

Hi @billnbell, thank you so much for the PR. I'll be off for a few days, but I'll make sure the review and land it when I'm back.

About your comments/suggestions:

OK. I will try USE_FRAMEWORKS=static - I did not see that change to the documentation!!! Docs missing... Or I cannot find them :) Instead of use_frameworks! :linkage => :static just add USE_FRAMEWORKS=static before running pod install.

There is some documentation of use_frameworks in the new architecture here. Under the hoods, both approaches should work in the same way as React Native observes whether you are using use_frameworks! with the USE_FRAMEWORKS env variable or with the Podfile approach (using use_frameworks! :linkage => :static) — implementation is here if you are curious.

That's why the usage of use_frameworks! :linkage => :static must happen before calling use_react_native!

The pods all need install_modules_dependencies(s) which is a change we need to communicate in the BLOG or something.

Completely agree… and it is already documented in the website! 😅

cipolleschi avatar Jul 09 '23 18:07 cipolleschi

@billnbell patch(es) is still needed on "react-native-svg": "13.10.0", (and 13.11) "react-native-screens": "3.24.0", "react-native-gesture-handler": "2.12.1", "react-native-pdf","6.7.1", "react-native-blob-util""0.19.0", and probably dozens more

using RN 0.72.3 (and 0.72.4)

with RCT_NEW_ARCH_ENABLED=1 bundle exec pod install and disabled flipper in Podfile.

I finally got it to build, thanks @billnbell !

Also needed: In podfile:

post_install do |installer| react_native_post_install( installer, config[:reactNativePath], :mac_catalyst_enabled => false ) ----v THIS PART installer.pods_project.targets.each do |target| if target.name == "RNScreens" append_header_search_path(target, "${PODS_ROOT}/../../node_modules/react-native/ReactCommon") end if target.name == "react-native-pdf" append_header_search_path(target, "${PODS_ROOT}/../../node_modules/react-native/ReactCommon") end ----^THIS PART end

---AND def append_header_search_path(target, path) target.build_configurations.each do |config| # Note that there's a space character after $(inherited). config.build_settings["HEADER_SEARCH_PATHS"] ||= "$(inherited) " config.build_settings["HEADER_SEARCH_PATHS"] << path end end

alex-strae avatar Aug 16 '23 08:08 alex-strae

Hi @alex-strae! We are trying to autofix 3rd party libraries here to avoid issue and to lighten the maintenance burden from the shoulder of lib maintainer. The update_search_paths function is called here.

Probably we just miss the search path that points to ReactCommon... 🤔 Could you try updating that function with the search path you need and removing the code you added in your own Podfile to see if it works? If yes, can you submit a PR? This change will make much easier to use frameworks for everyone!

(Otherwise, if you can provide a repro with the failure and a commit with the fix, I can port the fix to RN myself!)

Thank you so much!

cipolleschi avatar Aug 18 '23 10:08 cipolleschi

I had a PR for React-ImageManager and it is stuck in the process. Unsure where it will land. I tried to add it into 0.72.4 but it was rejected due to a conflict in main. Adding seemingly simple improvements are challenging.

billnbell avatar Aug 18 '23 20:08 billnbell

Hi @billnbell. This can happen unfortunately, as your commit was created on top of other changes in the Cocoapods infrastructure that made pretty hard to cherry-pick it safely. However, your changes are safely in main and would be available in 0.73.

One thing to make sure your changes would be into 0.72 is tofollow these steps:

  1. Clone react-native repo
  2. Checkout the 0.72-stable branch
  3. Apply your changes on that version of the codebase.
  4. Create a PR against the 0.72-stable branch instead of main.

Thanks to these steps, the release crew will be able to simply Squash and Merge your PR on the release branch, without the need of manually resolving the conflicts.

I'm sorry for the effort this process is requiring.

cipolleschi avatar Aug 21 '23 09:08 cipolleschi

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar Feb 18 '24 05:02 github-actions[bot]

This issue was closed because it has been stalled for 7 days with no activity.

github-actions[bot] avatar Feb 25 '24 05:02 github-actions[bot]