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

[BUG] - Can't Build project on iOS 15, throws "RCT_ENABLE_INSPECTOR needs to be set to fulfill RCT_REMOTE_PROFILE" #46144

Closed
gmantuanrosa opened this issue Aug 21, 2024 · 9 comments
Labels
Platform: iOS iOS applications.

Comments

@gmantuanrosa
Copy link

Description

My React-Native project is a brownfield app running on version 0.73.9 and expo version 50. I was setting iOS 13.0 as minimum version and we bumped to 15.0 to use some recent SwiftUI API. Now when I try to build the app it always throws the same issue: "RCT_ENABLE_INSPECTOR needs to be set to fulfill RCT_REMOTE_PROFILE"

// RCTDefines.h

/**
 * Sanity check that these compile-time flags are compatible. RCT_REMOTE_PROFILE requires RCT_PROFILE and
 * RCT_ENABLE_INSPECTOR
 */
#if RCT_REMOTE_PROFILE
#if !RCT_PROFILE
#error "RCT_PROFILE needs to be set to fulfill RCT_REMOTE_PROFILE"
#endif // RCT_PROFILE
#if !RCT_ENABLE_INSPECTOR
#error "RCT_ENABLE_INSPECTOR needs to be set to fulfill RCT_REMOTE_PROFILE"
#endif // RCT_ENABLE_INSPECTOR
#endif // RCT_REMOTE_PROFILE

Sometimes when I change the value of RCT_ENABLE_INSPECTOR on Podfile it says
RCTInspectorDevServerHelper.h not found or RCTDevLoadingViewProtocol.h not found on RCTBridge

// RCTBridge

#if RCT_ENABLE_INSPECTOR
#import "RCTInspectorDevServerHelper.h"
#endif
#import "RCTDevLoadingViewProtocol.h"

I've read over the internet (can't remember where) that I had to add some GCC_PREPROCESSOR_DEFINITIONS, so my Podfile contains this bit:

post_install do |installer_representation|
  react_native_post_install(
    installer_representation,
    config[:reactNativePath],
    :mac_catalyst_enabled => false
  )

  installer_representation.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '15.0'
      config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)', '_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION']
      config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] << 'RCT_ENABLE_INSPECTOR=0'
      config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] << 'ENABLE_PACKAGER_CONNECTION=0'

      xcconfig_path = config.base_configuration_reference.real_path
      xcconfig = File.read(xcconfig_path)
      xcconfig_mod = xcconfig.gsub(/DT_TOOLCHAIN_DIR/, "TOOLCHAIN_DIR")
      File.open(xcconfig_path, "w") { |file| file << xcconfig_mod }
    end
  end
end

Removing these values or changing between 0 and 1 always throws one or the other issue.

As mentioned before, the app was working fine on iOS version 12.4 and 13.0 (had to bump the version in order for Expo to work) and in all cases I am using Xcode 15

Steps to reproduce

  1. Create an iOS Project using iOS minimum version of 15.0;
  2. Follow steps to integrate React Native into iOS Project from React Native Documentation;
  3. Build project.

React Native Version

0.73.9

Affected Platforms

Runtime - iOS, Build - MacOS

Output of npx react-native info

System:
  OS: macOS 14.4.1
  CPU: (8) arm64 Apple M1
  Memory: 328.77 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 20.13.1
    path: ~/.nvm/versions/node/v20.13.1/bin/node
  Yarn:
    version: 3.6.4
    path: ~/.nvm/versions/node/v20.13.1/bin/yarn
  npm:
    version: 10.5.2
    path: ~/.nvm/versions/node/v20.13.1/bin/npm
  Watchman:
    version: 2024.05.06.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.13.0
    path: /Users/gianrosa/.rbenv/shims/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.5
      - iOS 17.5
      - macOS 14.5
      - tvOS 17.5
      - visionOS 1.2
      - watchOS 10.5
IDEs:
  Xcode:
    version: 15.4/15F31d
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.11
    path: /usr/bin/javac
  Ruby:
    version: 2.7.6
    path: /Users/gianrosa/.rbenv/shims/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  expo: 50
  react: 18.2.0
  react-native: 0.73.9
npmGlobalPackages:
  "*react-native*": Not Found
iOS:
  hermesEnabled: true
  newArchEnabled: false

Stacktrace or Logs

no stacktrace

Reproducer

no reproducible repository

Screenshots and Videos

Captura de Tela 2024-08-21 às 19 08 36

@react-native-bot react-native-bot added Platform: iOS iOS applications. Needs: Author Feedback Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. labels Aug 21, 2024
@react-native-bot
Copy link
Collaborator

⚠️ Missing Reproducible Example
ℹ️ 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.

@react-native-bot
Copy link
Collaborator

⚠️ Missing Reproducible Example
ℹ️ We could not detect a reproducible example in your issue report. Please provide either:

@OB42
Copy link

OB42 commented Aug 23, 2024

same here

@gmantuanrosa
Copy link
Author

gmantuanrosa commented Aug 23, 2024

I could pass this issue by adding a flag to the Podfile

config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] << 'RCT_REMOTE_PROFILE=0'

Apparently this issue is related to Debugger and Flipper (even though I am not using it)

**
 * RCT_REMOTE_PROFILE: RCT_PROFILE + RCT_ENABLE_INSPECTOR + enable the
 * connectivity functionality to control the profiler remotely, such as via Chrome DevTools or
 * Flipper.
 */
#ifndef RCT_REMOTE_PROFILE
#define RCT_REMOTE_PROFILE RCT_DEV
#endif


/**
 * Sanity check that these compile-time flags are compatible. RCT_REMOTE_PROFILE requires RCT_PROFILE and
 * RCT_ENABLE_INSPECTOR
 */
#if RCT_REMOTE_PROFILE // this block will be jumped entirely
#if !RCT_PROFILE
#error "RCT_PROFILE needs to be set to fulfill RCT_REMOTE_PROFILE"
#endif // RCT_PROFILE
#if !RCT_ENABLE_INSPECTOR
#error "RCT_ENABLE_INSPECTOR needs to be set to fulfill RCT_REMOTE_PROFILE"
#endif // RCT_ENABLE_INSPECTOR
#endif // RCT_REMOTE_PROFILE

But the issue now becomes a missing file (RCTDevLoadingViewProtocol.h) on RCTBridge.m file due to using use_frameworks!

#if RCT_ENABLE_INSPECTOR
#import "RCTInspectorDevServerHelper.h"
#endif
#import "RCTDevLoadingViewProtocol.h"

Some places says to use use_frameworks! :linkage => :static or use_modular_headers!. While the first option doesn't solve the issue and the missing file continues to persist, the second one works until Firebase starts to also be missing from the project.

I tried removing both use_frameworks and use_modular_headers! and applying modular_header => true to firebase pods directly but they don't work.

These libraries work

  pod 'Firebase', :modular_headers => true
  pod 'FirebaseCoreInternal', :modular_headers => true
  pod 'GoogleUtilities', :modular_headers => true
  pod 'FirebaseCore', :modular_headers => true

These throws an issue asking to use , :modular_headers => true or use_modular_headers!

  pod 'Firebase/Analytics', :modular_headers => true
  pod 'Firebase/Auth', :modular_headers => true
  pod 'Firebase/Core', :modular_headers => true
  pod 'Firebase/Crashlytics', :modular_headers => true
  pod 'Firebase/Database', :modular_headers => true
  pod 'Firebase/Storage', :modular_headers => true

I don't know what I could be doing wrong but it seems that some config breaks the Swift link and others break the React Native linking...

@github-actions github-actions bot added Needs: Attention Issues where the author has responded to feedback. and removed Needs: Author Feedback labels Aug 23, 2024
@Dhanyalalithamony
Copy link

Same here

@cipolleschi
Copy link
Contributor

Hey @gmantuanrosa! thanks for the issue.
The documentation of this step:

  1. Follow steps to integrate React Native into iOS Project from React Native Documentation;

Is very outdated and probably wrong.

That's not the right way to integrate a project anymore.
I have to find the time to update that page but I could not do it.

Your podfile, after the process, should look like this.
We do a lot of magic under the hoods so the podfile is super simpler and you don't have to deal with all the flags.

Let me know if you make progress there.

@gmantuanrosa
Copy link
Author

gmantuanrosa commented Aug 28, 2024

Hey @cipolleschi
As my scenario is a little bit different than usual, I think that some of the problems were here on my end, for instance, I have a single project with 2 different targets on the Podfile. The issue was more related to Expo configuration other than React Native one.

Having use_expo_modules! in one of the target worked normally, but since we were adding Expo to both targets I couldn't make it work in neither both targets or in a "global" way in the Podfile.

For React Native alone I had to move some of the configuration to be globally applied but the RCT_ENABLE_INSPECTOR issue was still happening. The issue was really solved by moving away from Expo and using a different library for my purpose.

My Podfile currently looks like:

# Resolve react_native_pods.rb with node to allow for hoisting
require Pod::Executable.execute_command('node', ['-p', 'require("path").resolve(__dirname, "../node_modules/react-native/scripts/react_native_pods.rb")']).strip

workspace 'project'

platform :ios, '15.0'
prepare_react_native_project!


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

# Override Firebase SDK Version
$FirebaseSDKVersion = '10.24.0'

def sharedPods
  pod 'Parse'
  pod 'Parse/FacebookUtils'
  pod 'AssetsPickerViewController'
  pod 'FBSDKCoreKit/Swift'
  pod 'FBSDKLoginKit/Swift'
  pod 'FBSDKShareKit/Swift'
  pod 'Firebase/Analytics'
  pod 'Firebase/Auth'
  pod 'Firebase/Core'
  pod 'Firebase/Crashlytics'
  pod 'Firebase/Database'
  pod 'Firebase/Storage'
  pod 'SwiftyJSON'
  pod "CleverTap-iOS-SDK"
end

target 'project-client' do
  sharedPods

  pod 'AppsFlyerFramework'
  pod 'ReachabilitySwift'
  pod 'SSZipArchive'
  pod 'Stripe'
end

target 'project-dash' do
  config = use_native_modules!
  
  use_react_native!(
    :path => config[:reactNativePath],
    # An absolute path to your application root.
    :app_path => "#{Pod::Config.instance.installation_root}/.."
  )

  sharedPods

  pod 'AppsFlyerFramework'
  pod 'ReachabilitySwift'
  pod 'SSZipArchive'
  pod 'Stripe'

  pre_install do |installer|
    installer.pod_targets.each do |pod|
      if pod.name.eql?('RNScreens') || pod.name.eql?('react-native-video')
        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,
      # :ccache_enabled => true
    )

    installer.pods_project.targets.each do |target|
      target.build_configurations.each do |config|
        config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '15.0'
        config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)', '_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION']
        config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] << 'RCT_REMOTE_PROFILE=0'

        xcconfig_path = config.base_configuration_reference.real_path
        xcconfig = File.read(xcconfig_path)
        xcconfig_mod = xcconfig.gsub(/DT_TOOLCHAIN_DIR/, "TOOLCHAIN_DIR")
        File.open(xcconfig_path, "w") { |file| file << xcconfig_mod }
      end
    end
  end
end

I'm also running USE_FRAMEWORKS=static pod install and it worked 😄

@cipolleschi
Copy link
Contributor

If the issue was with the Expo integration, I suggest also to open it on the Expo repository (https://github.com/expo/expo). They are pretty responsive and they might help out!

@cortinico cortinico removed Needs: Repro This issue could be improved with a clear list of steps to reproduce the issue. Needs: Attention Issues where the author has responded to feedback. labels Sep 11, 2024
@YadBro
Copy link

YadBro commented Oct 16, 2024

+1
(Using Yarn)
Node version: v20.13.1
Yarn Version: v3.6.4

package.json:
"react-native": "0.75.4",
"react": "18.3.1",

Podfile:

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

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 'lms_mobile' do
  config = use_native_modules!

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

  use_react_native!(
    :path => config[:reactNativePath],
    # An absolute path to your application root.
    :app_path => "#{Pod::Config.instance.installation_root}/.."
  )

  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,
      # :ccache_enabled => true
    )
  end
end

permissions_path = '../node_modules/react-native-permissions/ios'
pod 'Permission-LocationAlways', :path => "#{permissions_path}/LocationAlways/Permission-LocationAlways.podspec"
pod 'Permission-LocationWhenInUse', :path => "#{permissions_path}/LocationWhenInUse/Permission-LocationWhenInUse.podspec"
pod 'GoogleUtilities', :modular_headers => true

npx react-native doctor

⠸ Running diagnostics...* daemon not running; starting now at tcp:5037

  • daemon started successfully
    Common
    ✓ Node.js - Required to execute JavaScript code
    ✓ yarn - Required to install NPM dependencies
    ✓ Watchman - Used for watching changes in the filesystem when in development mode
    ● Metro - Metro Bundler is not running

Android
✖ Adb - No devices and/or emulators connected. Please create emulator with Android Studio or connect Android device.
✓ JDK - Required to compile Java code
✓ Android Studio - Required for building and installing your app on Android
✓ ANDROID_HOME - Environment variable that points to your Android SDK installation
✓ Gradlew - Build tool required for Android builds
✓ Android SDK - Required for building and installing your app on Android

iOS
✓ Xcode - Required for building and installing your app on iOS
✓ Ruby - Required for installing iOS dependencies
✓ CocoaPods - Required for installing iOS dependencies
● ios-deploy - Required for installing your app on a physical device with the CLI
✓ .xcode.env - File to customize Xcode environment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Platform: iOS iOS applications.
Projects
None yet
Development

No branches or pull requests

8 participants
@cortinico @cipolleschi @OB42 @react-native-bot @YadBro @gmantuanrosa @Dhanyalalithamony and others