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

[🐛] 🔥 Can't run pod install --repo-update --project-directory=ios with react native 0.75.2

Open NiharR027 opened this issue 1 year ago • 2 comments

Issue

I am trying to migrate from react native 0.74.5 to 0.75.2 using https://react-native-community.github.io/upgrade-helper/?from=0.74.5&to=0.75.2.

Now all was good until I ran pod install --repo-update --project-directory=ios

It gives the below error:


[!] Invalid `Podfile` file: No such file or directory @ rb_sysopen - /Users/[USER_NAME]/Projects/node_modules/@react-native-firebase/app/ios_config.sh.

 #  from /Users/[USER_NAME]/Projects/[PROJECT_NAME]/ios/Podfile:62
 #  -------------------------------------------
 #    $RNFirebaseAsStaticFramework = true #https://rnfirebase.io/#altering-cocoapods-to-use-frameworks
 >    config = use_native_modules!
 #
 #  -------------------------------------------

Going to iOS and manually running pod install works fine. But the problem is running from the root directory, it just doesn't like it.

I have tried to delete node modules / cleaning yarn cache etc. this works fine with react native v0.74.5.


Project Files

Javascript

Click To Expand

package.json:

    "@react-native-firebase/app": "^20.4.0",
    "@react-native-firebase/messaging": "^20.4.0",
    "react-native": "0.75.2",

iOS

Click To Expand

ios/Podfile:

  • [ ] I'm not using Pods
  • [x] I'm using Pods and my Podfile looks like:
def node_require(script)
  # Resolve script with node to allow for hoisting
  require Pod::Executable.execute_command('node', ['-p',
    "require.resolve(
      '#{script}',
      {paths: [process.argv[1]]},
    )", __dir__]).strip
end

node_require('react-native/scripts/react_native_pods.rb')
node_require('react-native-permissions/scripts/setup.rb')

platform :ios, min_ios_version_supported
prepare_react_native_project!

# ⬇️ uncomment wanted permissions
setup_permissions([
  'Camera',
  # 'Contacts',
  # 'FaceID',
  # 'LocationAccuracy',
  # 'LocationAlways',
  # 'LocationWhenInUse',
  # 'MediaLibrary',
  'Microphone',
  # 'Motion',
  'Notifications',
  # 'PhotoLibrary',
  # 'PhotoLibraryAddOnly',
  # 'Reminders',
  # 'Siri',
  # 'SpeechRecognition',
  # 'StoreKit',
])


$RNFirebaseAsStaticFramework = true


# This "pre_install" is required for react-native-permissions, as a workaround for
# adding use_frameworks!, which was a requirement for @react-native-firebase v15 onwards
# See: https://www.npmjs.com/package/react-native-permissions#user-content-workaround-for-use_frameworks-issues
# Convert all permission pods into static libraries
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;
        # Uncomment the line corresponding to your CocoaPods version
        Pod::BuildType.static_library # >= 1.9
        # Pod::Target::BuildType.static_library # < 1.9
      end
    end
  end
end

target 'Appname' do
  # use_frameworks! is required for @react-native-firebase v15 onwards
  use_frameworks! :linkage => :static
  $RNFirebaseAsStaticFramework = true #https://rnfirebase.io/#altering-cocoapods-to-use-frameworks
  config = use_native_modules!

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



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

  post_install do |installer|
    # There are issues building iOS with react-native-image-picker. As of 14 Sept 2023,
    # v7.0.0 was installed and we're getting the error: Could not build module 'React'
    # This comment, https://github.com/react-native-image-picker/react-native-image-picker/issues/2158#issuecomment-1612438367, suggests to add the following lines
    installer.pods_project.build_configurations.each do |config|
      config.build_settings["CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES"] = true
    end

    # 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
    )
    fix_deployment_target(installer)
    fix_xcode14_code_signing_bug(installer)


  end
end

target 'Appname-tvOS' do
  # Pods for Appname-tvOS
  
  # This is required for @react-native-firebase v15 onwards
  use_frameworks! :linkage => :static

  target 'Appname-tvOSTests' do
    inherit! :search_paths
    # Pods for testing
  end
end

def fix_deployment_target(installer)
  return if !installer
  project = installer.pods_project
  project_deployment_target = project.build_configurations.first.build_settings['IPHONEOS_DEPLOYMENT_TARGET']

  puts "Make sure all pods deployment target is #{project_deployment_target.green}"
  project.targets.each do |target|
    puts "  #{target.name}".blue
    target.build_configurations.each do |config|
      old_target = config.build_settings['IPHONEOS_DEPLOYMENT_TARGET']
      new_target = project_deployment_target
      next if old_target == new_target
      puts "    #{config.name}: #{old_target.yellow} -> #{new_target.green}"
      config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = new_target
    end
  end
end

# Review this with the XCode upgrade (>14.2) and remove if no longer required.
def fix_xcode14_code_signing_bug(installer)
  installer.pods_project.targets.each do |target|
    if target.respond_to?(:product_type) and target.product_type == "com.apple.product-type.bundle"
      target.build_configurations.each do |config|
          config.build_settings['CODE_SIGNING_ALLOWED'] = 'NO'
      end
    end
  end
end

NiharR027 avatar Aug 27 '24 07:08 NiharR027

Not sure what is happening, at least it works when you run in the ios/ directory.

It does appear that this path is incorrect:

[!] Invalid `Podfile` file: No such file or directory @ rb_sysopen - /Users/[USER_NAME]/Projects/node_modules/@react-native-firebase/app/ios_config.sh.

It seems [PROJECT_NAME] is missing from path.

russellwheatley avatar Aug 27 '24 08:08 russellwheatley

We're also seeing this behaviour after upgrading to 0.75, npx pod-install is a workaround but the problem is there.

thespacemanatee avatar Aug 28 '24 04:08 thespacemanatee

+1

elkinjosetm avatar Aug 28 '24 19:08 elkinjosetm

+1, i am not able to archive to xcode cloud due to this.

Error is:

[!] Invalid Podfile file: No such file or directory @ rb_sysopen - /Volumes/workspace/repository/ios/node_modules/@react-native-firebase/app/ios_config.sh.

roamifydev avatar Aug 30 '24 06:08 roamifydev

This could be related: https://github.com/reactwg/react-native-releases/issues/341

roamifydev avatar Aug 30 '24 07:08 roamifydev

I have a problem on Xcode Cloud and this is my solution: bash /Volumes/workspace/repository/ios/node_modules/@react-native-firebase/app/ios_config.sh chmod +x /Volumes/workspace/repository/ios/node_modules/@react-native-firebase/app/ios_config.sh ci_post_clone.txt

ngocdevv avatar Sep 01 '24 04:09 ngocdevv

Adding the linepod 'RNFBApp', :path => '../node_modules/@react-native-firebase/app' just before calling use_native_modules in Podfile fixed the issue in our case.

target 'your_app_name' do
  pod 'RNFBApp', :path => '../node_modules/@react-native-firebase/app'
  config = use_native_modules!
  ...
  use_react_native!(...)
  ...
end

UPDATE: We see no error on when installing pods, but this change removes [CP-User] [RNFB] Core Configuration build phase from the project.pbxproj! Thats not good.

hazyikmis avatar Sep 10 '24 13:09 hazyikmis

looks like RN v0.75.3 has fixed the "install from outside the ios folder using --project-directory" issue: https://github.com/facebook/react-native/releases/tag/v0.75.3

Will try and let you guys know

NiharR027 avatar Sep 19 '24 23:09 NiharR027

I had this problem in Xcloud and fixed it with this

ios/ci_scripts/ci_post_clone.sh

#!/bin/sh

brew install node
brew install cocoapods
brew install yarn
yarn install

cd ../../node_modules/@react-native-firebase/app
chmod 755 ios_config.sh

cd ../../..
cd ios
pod install

tellodaniel avatar Sep 26 '24 17:09 tellodaniel

Can confirm that the issue is resolved with 0.75.3 react native. https://github.com/invertase/react-native-firebase/issues/7993#issuecomment-2362365530

NiharR027 avatar Oct 01 '24 01:10 NiharR027

I Got an issue In RNFBmessaging like declaration of 'RCTPromiseResolveBlock' must be imported from module 'RNFBApp.RNFBAppModule' before it is required and other issues

My podefile

def node_require(script)

Resolve script with node to allow for hoisting

require Pod::Executable.execute_command('node', ['-p', "require.resolve( '#{script}', {paths: [process.argv[1]]}, )", dir]).strip end

Use it to require both react-native's and this package's scripts:

node_require('react-native/scripts/react_native_pods.rb') node_require('react-native-permissions/scripts/setup.rb')

rn_maps_path = '../node_modules/react-native-maps'

pod 'react-native-google-maps', :path => rn_maps_path

pod 'rn-fetch-blob', :path => '../node_modules/rn-fetch-blob'

platform :ios, '14' prepare_react_native_project!

setup_permissions([

'LocationAlways', 'LocationWhenInUse',

])

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

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

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

target 'Pingle_UserTests' do inherit! :complete

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.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["CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES"] = true config.build_settings['CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER'] = "NO" end end end `

and also got RCTConvert issues in various packages.

am I missed anything?

IndrakumarR avatar Oct 28 '24 16:10 IndrakumarR

@IndrakumarR with apologies, I can't really read your comment, the formatting is very difficult to follow and it doesn't seem to be asking a coherent question with an easily recognizable set of facts (https://stackoverflow.com/help/how-to-ask)

Further, it is on a closed issue, so I would not expect further support on this issue

mikehardy avatar Oct 28 '24 23:10 mikehardy