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

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

Open
1 of 2 tasks
NiharR027 opened this issue Aug 27, 2024 · 8 comments

Comments

@NiharR027
Copy link

NiharR027 commented Aug 27, 2024

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
  • 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 NiharR027 changed the title [🐛] Bug Report Title - Can't run pod install --repo-update --project-directory=ios with react native 0.75.2 [🐛] Can't run pod install --repo-update --project-directory=ios with react native 0.75.2 Aug 27, 2024
@NiharR027 NiharR027 changed the title [🐛] Can't run pod install --repo-update --project-directory=ios with react native 0.75.2 [🐛] 🔥 Can't run pod install --repo-update --project-directory=ios with react native 0.75.2 Aug 27, 2024
@russellwheatley
Copy link
Member

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.

@thespacemanatee
Copy link

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

@elkinjosetm
Copy link

+1

@roamifydev
Copy link

roamifydev commented Aug 30, 2024

+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
Copy link

This could be related: reactwg/react-native-releases#341

@ngocleexuan
Copy link

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

@hazyikmis
Copy link

hazyikmis commented Sep 10, 2024

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.

@NiharR027
Copy link
Author

NiharR027 commented Sep 19, 2024

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

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

No branches or pull requests

7 participants