facebook / react-native

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

RCTAppDelegate.h file not found #36611

Closed griarman closed 9 months ago

griarman commented 1 year ago

Description

I have updated my RN app from 0.70.6 to 0.71.4. The pod install working well. But when I'm trying to run the app it gave me the error saying RCTAppDelegate.h file not found. But I hadn't problems with android running

React Native Version

0.71.4

Output of npx react-native info

System: OS: macOS 13.2.1 CPU: (10) arm64 Apple M1 Max Memory: 732.19 MB / 32.00 GB Shell: 5.8.1 - /bin/zsh Binaries: Node: 16.14.1 - /usr/local/bin/node Yarn: 1.22.17 - /usr/local/bin/yarn npm: 8.5.0 - /usr/local/bin/npm Watchman: Not Found Managers: CocoaPods: 1.12.0 - /opt/homebrew/bin/pod SDKs: iOS SDK: Platforms: DriverKit 22.2, iOS 16.2, macOS 13.1, tvOS 16.1, watchOS 9.1 Android SDK: Not Found IDEs: Android Studio: 2021.2 AI-212.5712.43.2112.8609683 Xcode: 14.2/14C18 - /usr/bin/xcodebuild Languages: Java: 11.0.15 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: 18.2.0 => 18.2.0 react-native: 0.71.4 => 0.71.4 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found

Steps to reproduce

just need to run run ios

Snack, code example, screenshot, or link to a repository

Sorry it's a private repo, and I can't share the code with you

griarman commented 1 year ago

I found the issue, it was connected with an m1 chip, on intel, and on a real device it works normally

RSchneider94 commented 1 year ago

I found the issue, it was connected with an m1 chip, on intel, and on a real device it works normally

having the same issue here, did you figure out how to fix with an M1 or just worked with Intel?

griarman commented 1 year ago

yea I'm not sure what was the real problem, but deleting podfile.lock, pods, build and removing cache helped

RSchneider94 commented 1 year ago

yea I'm not sure what was the real problem, but deleting podfile.lock, pods, build and removing cache helped

thanks for answering! unfortunately here no way to make it work, tried all that and still with problems 😭

cuteWarmFrog commented 1 year ago

same problem, hope to find help...

RSchneider94 commented 1 year ago

I give a try again following these steps again and using Xcode that build was still failing, but when trying to run directly the react-native run-ios command it has built successfully and worked.

sheriffyusuf commented 1 year ago

This solution on stackoverflow helped me solve this issue. https://stackoverflow.com/questions/71933392/react-native-ios-undefined-symbols-for-architecture-x86-64

aaron-tpg commented 1 year ago

I was getting this error. I had created a new target, and that target wasn't in my Podfile. It disappeared after adding

target 'MyNewTarget' do
  inherit! :complete
end

within the larger target.

developaul-k commented 1 year ago

same issue 🥲

yshakouri commented 1 year ago

Same issue on M1 "react": "18.2.0", "react-native": "0.71.7"

ucheNkadiCode commented 1 year ago

I'm getting this issue as well

callmesilva commented 1 year ago

I got it fixed by following a console warning when building with scratch configuration on my Podfile, Instead of adding use_frameworks! :linkage => :static (as suggested on react native firebase package docs) I added use_modular_headers! just above the target initialization line,

Hope this works for you too

ucheNkadiCode commented 1 year ago

I was able to fixed this issue with by making sure use_frameworks! :linkage => :static was above use_react-native

require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
$RNFirebaseAsStaticFramework = true

platform :ios, min_ios_version_supported
deployment_target = '13.0'
prepare_react_native_project!
# 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

target 'AppName' do
  config = use_native_modules!

  # Flags change depending on the env values.
  flags = get_default_flags()

  # This has to come before use_react_native or you get AppDelegate or RCTEventEmitter not found
  use_frameworks! :linkage => :static

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

end

I added use_modular_headers! just above the target initialization line,

@callmesilva Is this use_modular_headers safe to use? Could it be away to get around the fact that use_frameworks is not supported on the new architecture?

callmesilva commented 1 year ago

I was able to fixed this issue with by making sure use_frameworks! :linkage => :static was above use_react-native

require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
$RNFirebaseAsStaticFramework = true

platform :ios, min_ios_version_supported
deployment_target = '13.0'
prepare_react_native_project!
# 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

target 'AppName' do
  config = use_native_modules!

  # Flags change depending on the env values.
  flags = get_default_flags()

  # This has to come before use_react_native or you get AppDelegate or RCTEventEmitter not found
  use_frameworks! :linkage => :static

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

end

I added use_modular_headers! just above the target initialization line,

@callmesilva Is this use_modular_headers safe to use? Could it be away to get around the fact that use_frameworks is not supported on the new architecture?

I tried the use_frameworks! :linkage => :static way but it was causing my app to miss the RCTAppDelegate.h file. Perhaps it is supported because it allowed me to install Firebase related pods, but somehow it was messing with the actual React Native package

keshav-raj commented 1 year ago

Facing the same issue, Any Workaround is there yet? upgraded from 0.63 to 0.71.7, After that this issue is happening

Danushka50 commented 1 year ago

same issue 🥲 upgraded from 0.63.5 to 0.71.7,


Update : Found this for resolve the issue.


But facing another issue in "rn-fetch-blob": "^0.12.0",

ios/Pods/Headers/Public/React-Core/React/RCTBridgeModule.h:12:9 'React/RCTJSThread.h' file not found This happed when I upgrade react native version from 0.63.5 to 0.71.7.

Screenshot 2023-05-19 at 12 56 16 PM

issues occurred in the following files

Is there any additional configurations that need to do or did I do any incorrect configuration. Any help on this.


Update : Found this for resolve the issue

npm install remove pod remove pod.lock reinstall the arch -x86_64 pod install --repo-update

Works for me.


Prathameshlabde commented 1 year ago

I am still getting the same error can anyone please suggest? my react-native version is 0.71.7

thanksyouall commented 1 year ago

same issue!

riyan10dec commented 1 year ago

Me too, same issue! Although, I see React-RCTAppDelegate on Development Pods

Screenshot 2023-06-15 at 10 23 18

But still not found. Already do this https://github.com/facebook/react-native/issues/35818#issuecomment-1536291846, but still same issue.

I'm using https://github.com/invertase/react-native-firebase

    "@react-native-firebase/analytics": "^18.0.0",
    "@react-native-firebase/app": "^18.0.0",
    "@react-native-firebase/crashlytics": "^18.0.0",
    "@react-native-firebase/database": "^18.0.0",
    "@react-native-firebase/messaging": "^18.0.0",
    "@react-native-firebase/perf": "^18.0.0",

and my RN version is 0.71.8, i'm using M1 chip

cipolleschi commented 1 year ago

@keshav-raj @Prathameshlabde @riyan10dec

Please, try the following steps:

I hope these steps may help solving your issues.

riyan10dec commented 1 year ago

Hi @cipolleschi , thanks for your response.

after I try your steps, when I build on XCode, I'm getting this error: Command PhaseScriptExecution failed with a nonzero exit code Screenshot 2023-06-16 at 18 13 48

This is my Podfile, in case you need to see

source 'https://cdn.cocoapods.org/'

require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
$RNFirebaseAsStaticFramework = true

platform :ios, min_ios_version_supported
prepare_react_native_project!
# 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

target 'Influence' do
  config = use_native_modules!
  # permissions_path = '../node_modules/react-native-permissions/ios'
  # pod 'Permission-AppTrackingTransparency', :path => "#{permissions_path}/AppTrackingTransparency"
  # pod 'Permission-MediaLibrary', :path => "#{permissions_path}/MediaLibrary"
  # pod 'Permission-PhotoLibrary', :path => "#{permissions_path}/PhotoLibrary"
  # pod 'Permission-Notifications', :path => "#{permissions_path}/Notifications"

  # Flags change depending on the env values.
  flags = get_default_flags()

  use_frameworks! :linkage => :static
  # $RNFirebaseAsStaticFramework = true
  use_react_native!(
    :path => config[:reactNativePath],
    :hermes_enabled => flags[:hermes_enabled],
    :fabric_enabled => flags[:fabric_enabled],
    # An absolute path to your application root.
    :app_path => "#{Pod::Config.instance.installation_root}/.."
    # 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 => false,
    # :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,
  )

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

  post_install do |installer|
    react_native_post_install(
      installer,
      # Set `mac_catalyst_enabled` to `true` in order to apply patches
      # necessary for Mac Catalyst builds
      :mac_catalyst_enabled => false
    )
    __apply_Xcode_12_5_M1_post_install_workaround(installer)
  end

#   # Fix Xcode 14 warnings like:
#   # warning: Run script build phase '[CP] Copy XCFrameworks' will be run during every build because it does not specify any outputs. To address this warning, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'ATargetNameHere' from project 'YourProjectName')
#   # Ref.: https://github.com/CocoaPods/CocoaPods/issues/11444
#   post_integrate do |installer|
#     main_project = installer.aggregate_targets[0].user_project
#     pods_project = installer.pods_project
#     targets = main_project.targets + pods_project.targets
#     targets.each do |target|
#       run_script_build_phases = target.build_phases.filter { |phase| phase.is_a?(Xcodeproj::Project::Object::PBXShellScriptBuildPhase) }
#       cocoapods_run_script_build_phases = run_script_build_phases.filter { |phase| phase.name.start_with?("[CP]") }
#       cocoapods_run_script_build_phases.each do |run_script|
#         next unless (run_script.input_paths || []).empty? && (run_script.output_paths || []).empty?
#         run_script.always_out_of_date = "1"
#       end
#     end
#     main_project.save
#     pods_project.save
#   end
end

Update 2

I found that the error above because of the

line 3: $(CURRENT_PROJECT_VERSION) + 1: syntax error: operand expected (error token is "$(CURRENT_PROJECT_VERSION) + 1")
Command PhaseScriptExecution failed with a nonzero exit code

I found the log on /Users/<user>/Library/Developer/Xcode/DerivedData/<project>/Logs/Build/blabla.xcactivitylog

Hope my solution help someone

cipolleschi commented 1 year ago

Hi @riyan10dec, just to understand, the error:

line 3: $(CURRENT_PROJECT_VERSION) + 1: syntax error: operand expected (error token is "$(CURRENT_PROJECT_VERSION) + 1")
Command PhaseScriptExecution failed with a nonzero exit code

Is local to your configuration, right? I have never seen the $(CURRENT_PROJECT_VERSION) + 1 anywhere in the React Native codebase...

riyan10dec commented 1 year ago

@cipolleschi Maybe from this lib (I'm using this lib to auto increment the build number, everytime i build APK and IPA file): https://github.com/stovmascript/react-native-version

My solution is to revert CURRENT_PROJECT_VERSION and MARKETING_VERSION on Info.plist to hardcoded version number Screenshot 2023-06-19 at 13 40 05

sabeti commented 1 year ago

For those who still have this issue, first make sure you opened "projectName".xcworkspace and not "projectName".xcodeproj in XCode.

chrisluo commented 1 year ago

If after trying all of the above and you are able to run on a real device, but not the simulator; try checking that the project, targets and pods build settings Excluded Architectures - Any iOS Simulator SDK are set to i386. My project build settings had it set to i386, but targets build settings had it set to arm64. I changed it to i386 for all and was able to run on a simulator.

Also you might have this in your Podfile if you are upgrading from an older react native project. This sets it back to arm64 after each pod install. Remove this as well.

installer.pods_project.build_configurations.each do |config|
  config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
end
tranminhnhat1005 commented 11 months ago

If you are using React Native Config, please check the Podfile.

You must define the target inside the abstract_target ex:

abstract_target 'YourProjectNameCommonPods' do
  config = use_native_modules!
  ...

  target 'YourTargetName' do
  end

  ...
  post_install do |installer|
  ...
KhanhtqProteans commented 11 months ago

https://github.com/facebook/react-native/issues/36611#issuecomment-1552463986 save my time

tuguilin1 commented 11 months ago

@cipolleschi hi, all the solutions above i tried but still has the issue。can you help me fix it, here is my 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, '14.0'
source 'https://github.com/CocoaPods/Specs.git'
prepare_react_native_project!

# 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

target 'AuthCoreWalletDemo' do
  config = use_native_modules!
  use_frameworks! :linkage => :static
  # 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.
    :hermes_enabled => false,#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 'AuthCoreAdapter', '0.1.9'
      pod 'ParticleAuthCore', '0.1.9'
      pod 'ParticleMPCCore', '0.1.9'
      pod 'Thresh', '0.1.9'

      pod 'ParticleWalletGUI', '1.0.2'
      pod 'ParticleWalletAPI', '1.0.2'
      pod 'ParticleNetworkBase', '1.0.2'
      pod 'ParticleAuthService', '1.0.2'
      pod 'ParticleWalletConnect', '1.0.2'
      pod 'ParticleBiconomy', '1.0.2'

      pod 'ParticleConnect',  '0.2.8'
      pod 'ConnectWalletConnectAdapter',  '0.2.8'
      pod 'ConnectEVMAdapter',  '0.2.8'
      pod 'ConnectSolanaAdapter',  '0.2.8'
      pod 'ConnectPhantomAdapter',  '0.2.8'
      pod 'ConnectCommon',  '0.2.8'
      pod 'ParticleAuthAdapter',  '0.2.8'

      pod 'SkeletonView', :git => 'https://github.com/SunZhiC/SkeletonView.git', :branch => 'main'
      pod 'SwiftMessages', :git => 'https://github.com/SunZhiC/SwiftMessages', :branch => 'master'

  target 'AuthCoreWalletDemoTests' do
    inherit! :complete
    # Pods for testing
  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)

    installer.pods_project.targets.each do |target|
      target.build_configurations.each do |config|
      config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
        end
      end

    # This is necessary for Xcode 14, because it signs resource bundles by default
    # when building for devices.
    installer.target_installation_results.pod_target_installation_results
    .each do |pod_name, target_installation_result|
      target_installation_result.resource_bundle_targets.each do |resource_bundle_target|
        resource_bundle_target.build_configurations.each do |config|
          config.build_settings['CODE_SIGNING_ALLOWED'] = 'NO'
        end
      end
    end

      installer.generated_projects.each do |project|
        project.targets.each do |target|
            target.build_configurations.each do |config|
                config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '14.0'
             end
        end
      end

        installer.pods_project.build_configurations.each do |config|
          config.build_settings['VALID_ARCHS'] = 'arm64, arm64e, x86_64'
        end
    end
end
cipolleschi commented 11 months ago

@tuguilin1 from your podfile, I can see you have a lot of custom Pod dependencies. Are they react native dependencies or iOS only ones?

RN dependencies must be installed through yarn add <dependency name> as, otherwise, the autolinking mechanism may fail.

Secondly, can you show the Xcode error you are encountering?

uloco commented 10 months ago

Got the same issue as soon as I enable static linking. I did everything as described here but could not manage to make it build on iOS. Always get 'React-RCTAppDelegate/RCTAppDelegate.h' file not found. I'm on react native 0.72.4 btw.

cipolleschi commented 10 months ago

@uloco, can you please provide a repro using this repo as a template?

uloco commented 10 months ago

Looks like it was some import order problem. We also import another dependency in AppDelegate.h, called #import <UserNotifications/UNUserNotificationCenter.h>, which was imported before #import <RCTAppDelegate.h> (It's from this repo: https://github.com/react-native-push-notification/ios.

After putting RCTAppDelegate.h to the very top, it started working again. Also I replaced React-RCTAppDelegate/RCTAppDelegate.h with just <RCTAppDelegate.h>, don't know if this made any difference though.

nandgreat commented 10 months ago

target 'MyNewTarget' do inherit! :complete end

Thank you so much for this... It worked perfectly

jackfiallos commented 10 months ago

Currently, I'm facing this too, and I have compared a new project vs. https://github.com/mikehardy/rnfbdemo/tree/main vs. my project.

I'm noticing something that may cause the issue, but not sure what this means, when checking the section "General" -> "Frameworks, Libraries, and Embedded Content", normally, it uses libPods-[project_name].a but mine has Pods_[project_name].framework.

I was wondering, what do you have there and what's the difference, how does this was created?

I've tried using RN 0.72.3 and 0.72.4, not sure about previous releases

cipolleschi commented 10 months ago

Hi @jackfiallos! The reason why you have .framework instead of a .a is because you are configuring your project to run with use_frameworks! rather than static libraries. So, Cocoapods creates frameworks instead of libraries (.a) and therefore the linking of external libraries is done using those.

jackfiallos commented 10 months ago

Thanks for clarifying @cipolleschi, that's what I thought ..

In the end, I could manage the error, tried different things and finally, it's working again, I believe my error was in the Podfile because it wasn't updated correctly. Also, I had a mix of different setups from other libraries that weren't updated so had configs from different versions. I think one of the misconfigurations was causing the issue with the project compilation.

I'm not sure what the issue was, but I'll suggest anybody having this problem, to check all your custom libraries and see if the configuration still applies to your current RN version.

Something to add is, the most important thing to verify is your Gemfile.lock file that effectively has:

DEPENDENCIES
  cocoapods (~> 1.12)

and before testing, remove from your root project, /vendor folder Gemfile.lock file and from ios folder, /Pods and Podfile.lock.

execute the bundle install and the pod install --repo-update (arch -x86_64 pod install --repo-update for M1/2 processors).

feedthedevil commented 10 months ago

same issue. upgrading from 0.66.5 to 0.72.4

cipolleschi commented 10 months ago

@feedthedevil it is likely that it depends on your Podfile or on some 3rd party dependency. Have a look at the conversation, there are various fixes, depending on different podfile setups and libraries involved. As a first step, try to have your Podfile as close as possible to this one

feedthedevil commented 10 months ago

@cipolleschi thank you for reply. I was upgrading by changing files finding differences via upgrade-helper and somehow in my AppDelegate.h i was importing RCTAppDelegate.h as React/RCTAppDelegate.h ;) Leaving just RCTAppDelegate.h helped to resolve the issue)

cimpianRadu commented 9 months ago

I was able to fix this by deleting ios/build folder and reinstalling the dependencies. But I am not sure what caused this, though 😅

Colemartindale commented 9 months ago

I am experiencing the same issue, RN 0.70.6 --> 0.72.5 Apple Silicon M1 I have tried every recommendation in this thread with no luck. Any suggestions would be greatly appreciated here is my 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!

# 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

target 'WolffMobile' do
  config = use_native_modules!

  # Flags change depending on the env values.cd ..
  flags = get_default_flags()

  use_react_native!(
    :path => config[:reactNativePath],
    # Hermes is now enabled by default. Disable by setting this flag to false.
    :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}/.."
  )

  target 'WolffMobileTests' do
    inherit! :complete
    # Pods for testing
  end
  target 'WolffMobileDev' do
    inherit! :complete
  end
  target 'WolffMobileStg' do
    inherit! :complete
  end

  post_install do |installer|
    installer.pods_project.targets.each do |target|
      target.build_configurations.each do |config|
          config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.4'
          config.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = "arm64"
        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,
      config[:reactNativePath],
      # Set `mac_catalyst_enabled` to `true` in order to apply patches
      # necessary for Mac Catalyst builds
      :mac_catalyst_enabled => false
    )
    __apply_Xcode_12_5_M1_post_install_workaround(installer)
  end

end
thornec commented 9 months ago

I am experiencing same issues after upgrading to rn 0.72.5

$RNFirebaseAsStaticFramework = true

require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/react-native-unimodules/cocoapods.rb'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'

platform :ios, '13.0'
deployment_target = '13.0'

require 'json'
podfile_properties = JSON.parse(File.read('./Podfile.properties.json')) rescue {}

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

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

target 'prmassist' do
  use_expo_modules!
  config = use_native_modules!

  flags = get_default_flags()

  use_frameworks! :linkage => :static

  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'

  pod 'RNCAsyncStorage', :path => '../node_modules/@react-native-async-storage/async-storage'
  pod 'BVLinearGradient', :path => '../node_modules/react-native-linear-gradient'
  pod 'Firebase/Analytics'
  pod 'Firebase/Messaging'
  pod 'lottie-react-native', :path => '../node_modules/lottie-react-native'
  pod 'lottie-ios', :path => '../node_modules/lottie-ios'
  pod 'RNSVG', :path => '../node_modules/react-native-svg'
  pod 'RCT-Folly', :podspec => '../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec'
  pod 'Permission-AppTrackingTransparency', :path => "#{permissions_path}/AppTrackingTransparency"
  pod 'Permission-BluetoothPeripheral', :path => "#{permissions_path}/BluetoothPeripheral"
  pod 'Permission-LocationAlways', :path => "#{permissions_path}/LocationAlways"
  pod 'Permission-LocationWhenInUse', :path => "#{permissions_path}/LocationWhenInUse"

  post_install do |installer|

    react_native_post_install(
      installer,
      config[:reactNativePath],
      :mac_catalyst_enabled => false
    )
    __apply_Xcode_12_5_M1_post_install_workaround(installer)

    installer.pods_project.targets.each do |target|
      target.build_configurations.each do |config|
        config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)', '_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION']
        config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0'
      end
    end

    installer.pods_project.targets.each do |target|
      if (target.name&.eql?('FBReactNativeSpec'))
        target.build_phases.each do |build_phase|
          if (build_phase.respond_to?(:name) && build_phase.name.eql?('[CP-User] Generate Specs'))
            target.build_phases.move(build_phase, 0)
          end
        end
      end
    end
  end

  post_integrate do |installer|
    begin
      expo_patch_react_imports!(installer)
    rescue => e
      Pod::UI.warn e
    end
  end

end
cipolleschi commented 9 months ago

@thornec is this an Expo app? If yes, please open the issue to expo.

For all the others, please redirect the questions to #38283 which is the same root cause of missing search patch. I'll try to address this issue next week, with high priority.

thornec commented 9 months ago

Not an expo app, just have some expo packages installed. should I refer to #38283 for a fix?

cipolleschi commented 9 months ago

Yes, the root cause is probably the same: one dependency that is not perfectly setup to work with use_frameworks! which is required by Firebase (or by another dependency). I'm going to systematically test the most common dependencies to look for failures. I already found one with react-native-gesture-handler (and opened a PR here: https://github.com/software-mansion/react-native-gesture-handler/pull/2635)

thornec commented 9 months ago

hi is there any update on a fix for this?

cipolleschi commented 9 months ago

It will take much more than a day to fix this. Several libraries would have to release a new version. The best way to help out here is to create a reproducer using the official reproducer with all the dependencies you need, so I can try to make it build, highlight which dependencies needs to be updated, open PRs and fix what needed to be fixed in React Native.

Asking ETAs on update will not help us moving faster.

Alwaz commented 8 months ago

If after trying all of the above and you are able to run on a real device, but not the simulator; try checking that the project, targets and pods build settings Excluded Architectures - Any iOS Simulator SDK are set to i386. My project build settings had it set to i386, but targets build settings had it set to arm64. I changed it to i386 for all and was able to run on a simulator.

Also you might have this in your Podfile if you are upgrading from an older react native project. This sets it back to arm64 after each pod install. Remove this as well.

installer.pods_project.build_configurations.each do |config|
  config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
end

This solution solved this AppDelegate issue but caused another issue with react-native-zego-zim

The following build commands failed:
    Ld /Users/username/Library/Developer/Xcode/DerivedData/Healthy-ajctxzurqyzyjzdpvbtoafkxnpux/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/react-native-zego-zim.build/Objects-normal/x86_64/Binary/react_native_zego_zim normal x86_64 (in target 'react-native-zego-zim' from project 'Pods')
(1 failure)
cipolleschi commented 8 months ago

The following build commands failed: Ld /Users/username/Library/Developer/Xcode/DerivedData/Healthy-ajctxzurqyzyjzdpvbtoafkxnpux/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/react-native-zego-zim.build/Objects-normal/x86_64/Binary/react_native_zego_zim normal x86_64 (in target 'react-native-zego-zim' from project 'Pods') (1 failure)

Sorry, but this message contains no specific error, so I can't help here.

devethan commented 7 months ago

I was getting this error. I had created a new target, and that target wasn't in my Podfile. It disappeared after adding

target 'MyNewTarget' do
  inherit! :complete
end

within the larger target.

In my case, this is works. But I don't have idea why it should be added in Podfile. Before updating Xcode version, there was no script for the new target