facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
118.16k stars 24.21k forks source link

'RCTDevSettings.h' file not found #39587

Open Stefanpgr opened 11 months ago

Stefanpgr commented 11 months ago

New Version

0.72.4

Old Version

0.70.8

Build Target(s)

ios simulator

Output of react-native info

System: OS: macOS 13.3.1 CPU: (8) arm64 Apple M1 Pro Memory: 102.48 MB / 16.00 GB Shell: version: "5.9" path: /bin/zsh Binaries: Node: version: 18.17.1 path: ~/.nvm/versions/node/v18.17.1/bin/node Yarn: version: 1.22.17 path: /opt/homebrew/bin/yarn npm: version: 9.6.7 path: ~/.nvm/versions/node/v18.17.1/bin/npm Watchman: version: 2023.07.24.00 path: /opt/homebrew/bin/watchman Managers: CocoaPods: version: 1.12.1 path: /opt/homebrew/bin/pod SDKs: iOS SDK: Platforms:

Issue and Reproduction Steps

Trying to build for ios simulator and I get this error

/node_modules/react-native/React/CxxBridge/RCTCxxBridge.mm:22:9 'React/RCTDevSettings.h' file not found

Pod File `# require_relative '../node_modules/react-native/scripts/react_native_pods'

require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

require_relative '../node_modules/react-native-permissions/scripts/setup'

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

$RNFirebaseAsStaticFramework = true config = use_native_modules!

platform :ios, min_ios_version_supported prepare_react_native_project!

platform :ios, '12.4'

install! 'cocoapods', :deterministic_uuids => false

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 => linkage.to_sym end

use_frameworks! :linkage => :static

target 'myApp' do

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 => 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}/.."

) pod 'React-RCTSettings', :path => '../node_modules/react-native/Libraries/Settings'

pod 'React-CoreModules', :path => '../node_modules/react-native/React/CoreModules' permissions_path = '../node_modules/react-native-permissions/ios' setup_permissions([

'AppTrackingTransparency',

'BluetoothPeripheral',

'Calendars',

'Camera', 'Contacts', 'FaceID', 'LocationAccuracy', 'LocationAlways', 'LocationWhenInUse',

'MediaLibrary',

'Microphone',

'Motion',

'Notifications', 'PhotoLibrary', 'PhotoLibraryAddOnly',

'Reminders',

'SpeechRecognition',

'StoreKit'

]) pod 'OpenSSL-Universal', :modular_headers => true

pod 'Permission-Camera', :path => "#{permissions_path}/Camera"

pod 'Permission-LocationAccuracy', :path => "#{permissions_path}/LocationAccuracy"

pod 'Permission-LocationAlways', :path => "#{permissions_path}/LocationAlways"

pod 'react-native-geolocation-service', path: '../node_modules/react-native-geolocation-service'

target 'myAppTests' do inherit! :complete

Pods for testing

end

pre_install do |installer| Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}

installer.pod_targets.each do |pod|
  if pod.name.eql?('RNPermissions') || pod.name.start_with?('Permission-')
    def pod.build_type;
      Pod::BuildType.static_library
    end
  end
end

end

post_install do |installer|

installer.target_installation_results.pod_target_installation_results.each do |pod_name, target_installation_result|

#   target_installation_result.native_target.build_configurations.each do |config|
#     # For third party modules who have React-bridging dependency to search correct headers
#     config.build_settings['HEADER_SEARCH_PATHS'] ||= '$(inherited) '
#     config.build_settings['HEADER_SEARCH_PATHS'] << '"$(PODS_ROOT)/Headers/Private/React-bridging/react/bridging" '
#     config.build_settings['HEADER_SEARCH_PATHS'] << '"$(PODS_CONFIGURATION_BUILD_DIR)/React-bridging/react_bridging.framework/Headers" '
#   end
# end
 # https://github.com/facebook/react-native/blob/main/packages/react-native/scripts/react_native_pods.rb#L197-L202
react_native_post_install(
  installer,
  # Set `mac_catalyst_enabled` to `true` in order to apply patches
  # necessary for Mac Catalyst builds
  config[:reactNativePath],
  :mac_catalyst_enabled => false
)

# NOTE: Change IPHONEOS_DEPLOYMENT_TARGET to 12.4.
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_ROOT}/../../node_modules/react-native/ReactCommon" '
    config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.4'
  end
end
__apply_Xcode_12_5_M1_post_install_workaround(installer)

end end `

github-actions[bot] commented 11 months ago
:warning: Missing Reproducible Example
:information_source: We could not detect a reproducible example in your issue report. Please provide either:
  • If your bug is UI related: a Snack
  • If your bug is build/update related: use our Reproducer Template. A reproducer needs to be in a GitHub repository under your username.
gobzila commented 11 months ago

@Stefanpgr Any updates on this? I encounter the same issue.

Stefanpgr commented 11 months ago

IPHONEOS_DEPLOYMENT_TARGET @gobzila Honestly do not know how I fixed it. However I took these steps

You can use this as reference to fix yours and make sure you followed the upgrade guidelines word for word here

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

require_relative '../node_modules/react-native-permissions/scripts/setup'

platform :ios, min_ios_version_supported prepare_react_native_project!

flipper_config = FlipperConfiguration.disabled

use_frameworks! :linkage => :static $RNFirebaseAsStaticFramework = true

target 'myApp' do config = use_native_modules!

flags = get_default_flags()

use_react_native!( :path => config[:reactNativePath], :hermes_enabled => flags[:hermes_enabled], :fabric_enabled => flags[:fabric_enabled], :app_path => "#{Pod::Config.instance.installation_root}/.." )

permissions_path = '../node_modules/react-native-permissions/ios' setup_permissions([ 'Camera', 'Contacts', 'FaceID', 'LocationAccuracy', 'LocationAlways', 'LocationWhenInUse', 'Notifications', 'PhotoLibrary', 'PhotoLibraryAddOnly', ]) pod 'OpenSSL-Universal', :modular_headers => true

pod 'react-native-geolocation-service', path: '../node_modules/react-native-geolocation-service'

target 'myAppTests' do inherit! :complete

Pods for testing

end

pre_install do |installer| Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}

installer.pod_targets.each do |pod|
  if pod.name.eql?('RNPermissions') || pod.name.start_with?('Permission-')
    def pod.build_type;
      Pod::BuildType.static_library
    end
  end
end

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`

vargajacint commented 8 months ago

It was same in here, but for me the following changes in the Podfile helped:

delphinebugner commented 8 months ago

I also had the RCTDevSettings.h' file not found error (doing the 0.73 upgrade from 0.72). It took me a ridiculous amount of time to realize what was wrong in my podfile 🤦‍♀️

-> I was doing the post_install loop outside the target!

So my advices here:

julianD77 commented 5 months ago

Thanks for all the suggestions above - the key line that helped us to resolve the 'React/RCTDevSettings.h' file not found build error was to ensure that the following config statement was within our target block.

target 'TheApp' do
  config = use_native_modules!
  ...

As recommended above, following the reference Upgrade Helper Podfile helped us to track this down.

With previous versions of RN having this config statement outside of the target block did not seem to be a problem.

mrsasuuBeast commented 4 months ago

I was facing the same issue 'React/RCTDevSettings.h' file not found. My podfile has 2 targets (production and staging). I made it work moving config = use_native_modules!and post_install inside one target and removing the other one. The issue I am having now is the only way I made it work was defining the post_install inside the target but Podfile should have only one post_install hook defined so I am stuck for the second target.

Anyone had a similar issue?