Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
billnbell opened this issue Jul 5, 2023 · 19 comments
Closed
Labels
Needs: Triage 🔍 Stale There has been a lack of activity on this issue and it may be closed soon. Type: Question Issues that are actually questions and not bug reports.

Comments

@billnbell
Copy link
Contributor

billnbell commented Jul 5, 2023

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 billnbell changed the title New Arch 0.72.1 issue with use_frameworks! New Arch 0.72.1 issue with use_frameworks! - file not found.How to fix? Jul 5, 2023
@cortinico cortinico added the Type: Question Issues that are actually questions and not bug reports. label Jul 5, 2023
@github-actions
Copy link

github-actions bot commented Jul 5, 2023

⚠️ Issue is a Question
ℹ️ 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 github-actions bot closed this as completed Jul 5, 2023
@billnbell
Copy link
Contributor Author

billnbell commented Jul 6, 2023

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 - reactwg/react-native-new-architecture#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.

@cortinico
Copy link
Contributor

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

@billnbell
Copy link
Contributor Author

OK it is updated thanks.

@cipolleschi
Copy link
Contributor

cipolleschi commented Jul 6, 2023

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 cipolleschi reopened this Jul 6, 2023
@billnbell
Copy link
Contributor Author

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
Copy link
Contributor Author

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

@cipolleschi
Copy link
Contributor

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.

@billnbell
Copy link
Contributor Author

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
Copy link
Contributor Author

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

@billnbell
Copy link
Contributor Author

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
Copy link
Contributor Author

#38247

@cipolleschi
Copy link
Contributor

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! 😅

@alex-strae
Copy link

alex-strae commented Aug 16, 2023

@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

@cipolleschi
Copy link
Contributor

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!

@billnbell
Copy link
Contributor Author

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.

@cipolleschi
Copy link
Contributor

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.

Copy link

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 github-actions bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Feb 18, 2024
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs: Triage 🔍 Stale There has been a lack of activity on this issue and it may be closed soon. Type: Question Issues that are actually questions and not bug reports.
Projects
None yet
Development

No branches or pull requests

4 participants