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

Regression -- 0.72 fails to compile on iOS with use_frameworks! :linkage => :static when using pnpm #38140

Closed
evelant opened this issue Jun 30, 2023 · 28 comments
Labels
Impact: Regression Describes a behavior that used to work on a prior release, but stopped working recently. Needs: Triage 🔍 Platform: iOS iOS applications. Type: Upgrade Issue Issues reported from upgrade issue form

Comments

@evelant
Copy link

evelant commented Jun 30, 2023

New Version

0.72.1

Old Version

0.71.11

Build Target(s)

iOS development

Output of react-native info

info Fetching system and libraries information...
System:
  OS: macOS 13.4
  CPU: (10) arm64 Apple M1 Pro
  Memory: 63.72 MB / 16.00 GB
  Shell:
    version: 0.80.0
    path: /Users/imagio/.cargo/bin/nu
Binaries:
  Node:
    version: 18.16.0
    path: ~/Library/Caches/fnm_multishells/62216_1687887822404/bin/node
  Yarn:
    version: 1.22.19
    path: ~/Library/pnpm/yarn
  npm:
    version: 9.7.2
    path: ~/Library/pnpm/npm
  Watchman: Not Found
Managers:
  CocoaPods:
    version: 1.11.3
    path: /Users/imagio/.asdf/shims/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 22.4
      - iOS 16.4
      - macOS 13.3
      - tvOS 16.4
      - watchOS 9.4
  Android SDK: Not Found
IDEs:
  Android Studio: Flamingo 2022.2.1 Patch 2 Flamingo 2022.2.1 Patch 2
  Xcode:
    version: 14.3.1/14E300c
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.4.1
    path: /usr/bin/javac
  Ruby:
    version: 3.1.2
    path: /Users/imagio/.asdf/shims/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.72.1
    wanted: 0.72.1
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: true
  newArchEnabled: false

Issue and Reproduction Steps

Reproduction: https://github.com/evelant/rn072-pnpm-monorepo-ios-frameworks-static-bug

React-native 0.72 fails to compile for iOS when using use_frameworks! :linkage => :static


The following build commands failed:
	CompileC /Users/imagio/Library/Developer/Xcode/DerivedData/testproj-aijjqxpffhriwvdbnbtslrapnlmx/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/React-utils.build/Objects-normal/arm64/RunLoopObserver.o /Users/imagio/dev/test/node_modules/.pnpm/react-native@0.72.1_@babel+core@7.20.2_@babel+preset-env@7.20.2_react@18.2.0/node_modules/react-native/ReactCommon/react/utils/RunLoopObserver.cpp normal arm64 c++ com.apple.compilers.llvm.clang.1_0.compiler (in target 'React-utils' from project 'Pods')
(1 failure)

To reproduce:
pnpm install
cd apps/testproj/ios
USE_FRAMEWORKS=static pod install
cd ..
pnpm react-native run-ios

@evelant evelant added Needs: Triage 🔍 Type: Upgrade Issue Issues reported from upgrade issue form labels Jun 30, 2023
@github-actions github-actions bot added Impact: Regression Describes a behavior that used to work on a prior release, but stopped working recently. Platform: iOS iOS applications. labels Jun 30, 2023
@cipolleschi
Copy link
Contributor

We have tests in CI that checks that the static frameworks builds (e.g.: Old Arch, Static Frameworks and Old Arch, dynamic frameworks)
and they work on the new arch as well (e.g.: Hermes, JSC)

These create a new app from the templates and install the pods accordingly, so that shouldn't happen.
Could it be a problem of pnpm? That's a setup we are actually not testing.

Also, this error:

The following build commands failed:
	CompileC /Users/imagio/Library/Developer/Xcode/DerivedData/testproj-aijjqxpffhriwvdbnbtslrapnlmx/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/React-utils.build/Objects-normal/arm64/RunLoopObserver.o /Users/imagio/dev/test/node_modules/.pnpm/react-native@0.72.1_@babel+core@7.20.2_@babel+preset-env@7.20.2_react@18.2.0/node_modules/react-native/ReactCommon/react/utils/RunLoopObserver.cpp normal arm64 c++ com.apple.compilers.llvm.clang.1_0.compiler (in target 'React-utils' from project 'Pods')
(1 failure)

Doesn't really told us anything: it only says that it failed to build RunLoopObserver.cpp but not why... :/

Could you provide the whole build log, uploading it somewhere?

@evelant
Copy link
Author

evelant commented Jun 30, 2023

@cipolleschi apologies! I copy pasted the wrong snippet 🤦

The failure in RunLoopObserver.cpp is 'react/debug/react_native_assert.h' file not found.

CompileC /Users/imagio/Library/Developer/Xcode/DerivedData/testproj-apwspzmyimbgmwevshwwgfiakwkt/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/React-utils.build/Objects-normal/arm64/RunLoopObserver.o /Users/imagio/dev/rn072-pnpm-monorepo-ios-frameworks-static-bug/node_modules/.pnpm/react-native@0.72.1_@babel+core@7.20.2_@babel+preset-env@7.20.2_react@18.2.0/node_modules/react-native/ReactCommon/react/utils/RunLoopObserver.cpp normal arm64 c++ com.apple.compilers.llvm.clang.1_0.compiler (in target 'React-utils' from project 'Pods')
    cd /Users/imagio/dev/rn072-pnpm-monorepo-ios-frameworks-static-bug/apps/testproj/ios/Pods
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x c++ -ivfsstatcache /Users/imagio/Library/Developer/Xcode/DerivedData/SDKStatCaches.noindex/iphonesimulator16.4-20E238-.sdkstatcache -target arm64-apple-ios12.4-simulator -fmessage-length\=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit\=0 -std\=c++17 -stdlib\=libc++ -fmodules -gmodules -fmodules-cache-path\=/Users/imagio/Library/Developer/Xcode/DerivedData/ModuleCache.noindex -fmodules-prune-interval\=86400 -fmodules-prune-after\=345600 -fbuild-session-file\=/Users/imagio/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/Session.modulevalidation -fmodules-validate-once-per-build-session -Wnon-modular-include-in-framework-module -Werror\=non-modular-include-in-framework-module -fmodule-name\=React_utils -Wno-trigraphs -fpascal-strings -O0 -fno-common -Wno-missing-field-initializers -Wno-missing-prototypes -Werror\=return-type -Wdocumentation -Wunreachable-code -Werror\=deprecated-objc-isa-usage -Werror\=objc-root-class -Wno-non-virtual-dtor -Wno-overloaded-virtual -Wno-exit-time-destructors -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wuninitialized -Wconditional-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wno-float-conversion -Wnon-literal-null-conversion -Wobjc-literal-conversion -Wshorten-64-to-32 -Wno-newline-eof -Wno-c++11-extensions -Wno-implicit-fallthrough -DPOD_CONFIGURATION_DEBUG\=1 -DDEBUG\=1 -DCOCOAPODS\=1 -D_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator16.4.sdk -fstrict-aliasing -Wdeprecated-declarations -Winvalid-offsetof -g -fvisibility-inlines-hidden -Wno-sign-conversion -Winfinite-recursion -Wmove -Wcomma -Wblock-capture-autoreleasing -Wstrict-prototypes -Wrange-loop-analysis -Wno-semicolon-before-method-body -Wunguarded-availability -index-store-path /Users/imagio/Library/Developer/Xcode/DerivedData/testproj-apwspzmyimbgmwevshwwgfiakwkt/Index.noindex/DataStore -iquote /Users/imagio/Library/Developer/Xcode/DerivedData/testproj-apwspzmyimbgmwevshwwgfiakwkt/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/React-utils.build/React_utils-generated-files.hmap -I/Users/imagio/Library/Developer/Xcode/DerivedData/testproj-apwspzmyimbgmwevshwwgfiakwkt/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/React-utils.build/React_utils-own-target-headers.hmap -I/Users/imagio/Library/Developer/Xcode/DerivedData/testproj-apwspzmyimbgmwevshwwgfiakwkt/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/React-utils.build/React_utils-all-non-framework-target-headers.hmap -ivfsoverlay /Users/imagio/Library/Developer/Xcode/DerivedData/testproj-apwspzmyimbgmwevshwwgfiakwkt/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/React-utils.build/all-product-headers.yaml -iquote /Users/imagio/Library/Developer/Xcode/DerivedData/testproj-apwspzmyimbgmwevshwwgfiakwkt/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/React-utils.build/React_utils-project-headers.hmap -I/Users/imagio/Library/Developer/Xcode/DerivedData/testproj-apwspzmyimbgmwevshwwgfiakwkt/Build/Products/Debug-iphonesimulator/React-utils/include -I/Users/imagio/Library/Developer/Xcode/DerivedData/testproj-apwspzmyimbgmwevshwwgfiakwkt/Build/Products/Debug-iphonesimulator/ReactCommon-Samples/ReactCommon_Samples.framework/Headers -I/Users/imagio/Library/Developer/Xcode/DerivedData/testproj-apwspzmyimbgmwevshwwgfiakwkt/Build/Products/Debug-iphonesimulator/ReactCommon/ReactCommon.framework/Headers/react/nativemodule/core -I/Users/imagio/Library/Developer/Xcode/DerivedData/testproj-apwspzmyimbgmwevshwwgfiakwkt/Build/Products/Debug-iphonesimulator/ReactCommon-Samples/ReactCommon_Samples.framework/Headers/platform/ios -I/Users/imagio/Library/Developer/Xcode/DerivedData/testproj-apwspzmyimbgmwevshwwgfiakwkt/Build/Products/Debug-iphonesimulator/React-NativeModulesApple/React_NativeModulesApple.framework/Headers -I/Users/imagio/Library/Developer/Xcode/DerivedData/testproj-apwspzmyimbgmwevshwwgfiakwkt/Build/Products/Debug-iphonesimulator/React-graphics/React_graphics.framework/Headers/react/renderer/graphics/platform/ios -I/Users/imagio/dev/rn072-pnpm-monorepo-ios-frameworks-static-bug/apps/testproj/ios/Pods/RCT-Folly -I/Users/imagio/dev/rn072-pnpm-monorepo-ios-frameworks-static-bug/apps/testproj/node_modules/react-native/ReactCommon/react/utils -I/Users/imagio/dev/rn072-pnpm-monorepo-ios-frameworks-static-bug/apps/testproj/node_modules/react-native/ReactCommon/react/utils/ReactCommon -I/Users/imagio/Library/Developer/Xcode/DerivedData/testproj-apwspzmyimbgmwevshwwgfiakwkt/Build/Products/Debug-iphonesimulator/React-debug/React_debug.framework/Headers -I/Users/imagio/dev/rn072-pnpm-monorepo-ios-frameworks-static-bug/apps/testproj/ios/Pods/RCT-Folly -I/Users/imagio/dev/rn072-pnpm-monorepo-ios-frameworks-static-bug/apps/testproj/ios/Pods/DoubleConversion -I/Users/imagio/dev/rn072-pnpm-monorepo-ios-frameworks-static-bug/apps/testproj/ios/Pods/boost -I/Users/imagio/Library/Developer/Xcode/DerivedData/testproj-apwspzmyimbgmwevshwwgfiakwkt/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/React-utils.build/DerivedSources-normal/arm64 -I/Users/imagio/Library/Developer/Xcode/DerivedData/testproj-apwspzmyimbgmwevshwwgfiakwkt/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/React-utils.build/DerivedSources/arm64 -I/Users/imagio/Library/Developer/Xcode/DerivedData/testproj-apwspzmyimbgmwevshwwgfiakwkt/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/React-utils.build/DerivedSources -F/Users/imagio/Library/Developer/Xcode/DerivedData/testproj-apwspzmyimbgmwevshwwgfiakwkt/Build/Products/Debug-iphonesimulator/React-utils -F/Users/imagio/Library/Developer/Xcode/DerivedData/testproj-apwspzmyimbgmwevshwwgfiakwkt/Build/Products/Debug-iphonesimulator/DoubleConversion -F/Users/imagio/Library/Developer/Xcode/DerivedData/testproj-apwspzmyimbgmwevshwwgfiakwkt/Build/Products/Debug-iphonesimulator/RCT-Folly -F/Users/imagio/Library/Developer/Xcode/DerivedData/testproj-apwspzmyimbgmwevshwwgfiakwkt/Build/Products/Debug-iphonesimulator/React-debug -F/Users/imagio/Library/Developer/Xcode/DerivedData/testproj-apwspzmyimbgmwevshwwgfiakwkt/Build/Products/Debug-iphonesimulator/fmt -F/Users/imagio/Library/Developer/Xcode/DerivedData/testproj-apwspzmyimbgmwevshwwgfiakwkt/Build/Products/Debug-iphonesimulator/glog -F/Users/imagio/Library/Developer/Xcode/DerivedData/testproj-apwspzmyimbgmwevshwwgfiakwkt/Build/Products/Debug-iphonesimulator/libevent -DFOLLY_NO_CONFIG -DFOLLY_MOBILE\=1 -DFOLLY_USE_LIBCPP\=1 -Wno-comma -Wno-shorten-64-to-32 -include /Users/imagio/dev/rn072-pnpm-monorepo-ios-frameworks-static-bug/apps/testproj/ios/Pods/Target\ Support\ Files/React-utils/React-utils-prefix.pch -MMD -MT dependencies -MF /Users/imagio/Library/Developer/Xcode/DerivedData/testproj-apwspzmyimbgmwevshwwgfiakwkt/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/React-utils.build/Objects-normal/arm64/RunLoopObserver.d --serialize-diagnostics /Users/imagio/Library/Developer/Xcode/DerivedData/testproj-apwspzmyimbgmwevshwwgfiakwkt/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/React-utils.build/Objects-normal/arm64/RunLoopObserver.dia -c /Users/imagio/dev/rn072-pnpm-monorepo-ios-frameworks-static-bug/node_modules/.pnpm/react-native@0.72.1_@babel+core@7.20.2_@babel+preset-env@7.20.2_react@18.2.0/node_modules/react-native/ReactCommon/react/utils/RunLoopObserver.cpp -o /Users/imagio/Library/Developer/Xcode/DerivedData/testproj-apwspzmyimbgmwevshwwgfiakwkt/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/React-utils.build/Objects-normal/arm64/RunLoopObserver.o -index-unit-output-path /Pods.build/Debug-iphonesimulator/React-utils.build/Objects-normal/arm64/RunLoopObserver.o
/Users/imagio/dev/rn072-pnpm-monorepo-ios-frameworks-static-bug/node_modules/.pnpm/react-native@0.72.1_@babel+core@7.20.2_@babel+preset-env@7.20.2_react@18.2.0/node_modules/react-native/ReactCommon/react/utils/RunLoopObserver.cpp:10:10: fatal error: 'react/debug/react_native_assert.h' file not found
#include <react/debug/react_native_assert.h>
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

Here's a full build log: https://gist.github.com/evelant/2e1479de86cde27e287f07974c9b8d53

@evelant
Copy link
Author

evelant commented Jun 30, 2023

IIRC there was an issue with header paths that was pnpm specific in previous versions but it got fixed. Here it is: #34102

@evelant
Copy link
Author

evelant commented Jun 30, 2023

Here's the reproduction without using pnpm, same failure

https://github.com/evelant/rn072-ios-frameworks-static-failure

@cipolleschi
Copy link
Contributor

can you try running USE_FRAMEWORKS=static NO_FLIPPER=1 pod install?
Flipper is not compatible with use_frameworks (and it will never be).

@evelant evelant changed the title Regression -- 0.72 fails to compile on iOS with use_frameworks! :linkage => :static Regression -- 0.72 fails to compile on iOS with use_frameworks! :linkage => :static when using pnpm Jun 30, 2023
@evelant
Copy link
Author

evelant commented Jun 30, 2023

This is a pnpm issue -- failure is the same with NO_FLIPPER=1 on the pnpm reproduction. Most likely a resurfacing of #34102 due to how headers at symlinked paths in the pnpm store get copied

@evelant
Copy link
Author

evelant commented Jun 30, 2023

This is indeed the same issue as before. I don't remember how it got resolved unfortunately. The problem is that the headers get copied into the wrong directory:

@evelant
Copy link
Author

evelant commented Jun 30, 2023

Related commits and issues:

8131b7b
#25349

@evelant
Copy link
Author

evelant commented Jun 30, 2023

@cipolleschi I found and fixed the issue, although I'm not sure if my solution is ideal.

The problem is that cocoapods doesn't resolve the symlink when header_mappings_dir is set in the podspec. That causes headers to get copied as a relative path to the inside of the pnpm store instead of to their actual output directory. You end up with headers in Build/node_modules/.pnpm/react-native/node_modules/react-native/ReactCommon/react/...etc instead of in the framework dirs.

To fix this I altered the podspecs to resolve the absolute paths for header_mappings_dir. I also fixed a number of search paths that didn't work correctly (I think they may have always been incorrect but worked by luck with yarn).

Here's a patch
react-native@0.72.1.patch

@Janak-Nirmal
Copy link

@evelant how to apply above patch ? when tried with patch-package it says invalid patch file

@evelant
Copy link
Author

evelant commented Jul 1, 2023

@Janak-Nirmal I think the patch file is just missing a newline at the end. Add one and it should apply.

@cipolleschi
Copy link
Contributor

Hi @evelant! I had a look at the patch and most of the changes looks good, actually.

Would you mind to create a PR against the React Native main branch so we can make sure we don't break such use case in the future and we can discuss the specific changes?

@evelant
Copy link
Author

evelant commented Jul 3, 2023

@cipolleschi done #38158

@goguda
Copy link

goguda commented Jul 6, 2023

So, I'm encountering the same error on 0.72.1 and 0.73 nightly, and I've never used pnpm. Using yarn here.

Cleared node_modules, Podfile.lock and Pods/ dir and XCode DerivedData between versions with no luck. Tried the patch as well on 0.72 and 0.73 with no luck.

Podfile:

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

$RNFirebaseAnalyticsWithoutAdIdSupport = true
$RNGoogleMobileAdsAsStaticFramework = true
platform :ios, min_ios_version_supported
prepare_react_native_project!

target 'roomi_app' do
  
  
  permissions_path = '../node_modules/react-native-permissions/ios'
  rn_maps_path = '../node_modules/react-native-maps'

  
  config = use_native_modules!

  flags = get_default_flags()
  
  use_frameworks! :linkage => :static
  pod 'Permission-LocationWhenInUse', :path => "#{permissions_path}/LocationWhenInUse"
  pod 'Permission-PhotoLibrary', :path => "#{permissions_path}/PhotoLibrary"
  pod 'Permission-Camera', :path => "#{permissions_path}/Camera"

  pod 'react-native-maps', path: rn_maps_path
  pod 'GoogleMaps'
  pod 'FirebaseCoreExtension', :modular_headers => true
  pod 'FirebaseInstallations', :modular_headers => true
  pod 'GoogleDataTransport', :modular_headers => true
  pod 'nanopb', :modular_headers => true
  pod 'FirebaseCore', :modular_headers => true
  pod 'FirebaseCoreInternal', :modular_headers => true
  pod 'GoogleUtilities', :modular_headers => true
  pod 'react-native-google-maps', path: rn_maps_path
  
  pod 'react-native-branch', path: '../node_modules/react-native-branch'
  pod 'FirebaseAnalytics/WithoutAdIdSupport'

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

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

  # Enables Flipper.
  #
  # Note that if you have use_frameworks! enabled, Flipper will not work and
  # you should disable the next line.
  # use_flipper!()
  
  def configure_branch_settings(target)
    target.build_configurations.each do |config|
     config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = ['$(inherited)', 'BRANCH_EXCLUDE_IDFA_CODE=1']
    end
  end

  pre_install do |installer|
    Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}
  
    installer.pod_targets.each do |pod|
      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

  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|
      if target.name == 'Branch'
        configure_branch_settings(target)
      end
    end
    installer.pods_project.targets.each do |target|
      if target.name == 'RCT-Folly'
        target.build_configurations.each do |config|
          config.build_settings['HEADER_SEARCH_PATHS'] = "$(inherited) ${PODS_ROOT}/fmt/include"
        end
      end
    end
    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']
      end
      if target.name == 'react-native-google-maps'
        target.build_configurations.each do |config|
          config.build_settings['CLANG_ENABLE_MODULES'] = 'No'
        end
      end
      target.build_configurations.each do |config|
        if config.name != "Release"
          config.build_settings['DEVELOPMENT_TEAM'] = "XXXXXXXXXX"
        else
          config.build_settings['DEVELOPMENT_TEAM'] = "XXXXXXXXXX"
        end
      end
    end
  end
end

And my build log, error on line 11228:

/Users/david/Documents/iroomit/node_modules/react-native/ReactCommon/react/utils/RunLoopObserver.cpp:10:10: fatal error: 'react/debug/react_native_assert.h' file not found

Build 2023-07-06T13-56-37.txt

@goguda
Copy link

goguda commented Jul 6, 2023

So, I'm encountering the same error on 0.72.1 and 0.73 nightly, and I've never used pnpm. Using yarn here.

Cleared node_modules, Podfile.lock and Pods/ dir and XCode DerivedData between versions with no luck. Tried the patch as well on 0.72 and 0.73 with no luck.

Podfile:

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

$RNFirebaseAnalyticsWithoutAdIdSupport = true
$RNGoogleMobileAdsAsStaticFramework = true
platform :ios, min_ios_version_supported
prepare_react_native_project!

target 'roomi_app' do
  
  
  permissions_path = '../node_modules/react-native-permissions/ios'
  rn_maps_path = '../node_modules/react-native-maps'

  
  config = use_native_modules!

  flags = get_default_flags()
  
  use_frameworks! :linkage => :static
  pod 'Permission-LocationWhenInUse', :path => "#{permissions_path}/LocationWhenInUse"
  pod 'Permission-PhotoLibrary', :path => "#{permissions_path}/PhotoLibrary"
  pod 'Permission-Camera', :path => "#{permissions_path}/Camera"

  pod 'react-native-maps', path: rn_maps_path
  pod 'GoogleMaps'
  pod 'FirebaseCoreExtension', :modular_headers => true
  pod 'FirebaseInstallations', :modular_headers => true
  pod 'GoogleDataTransport', :modular_headers => true
  pod 'nanopb', :modular_headers => true
  pod 'FirebaseCore', :modular_headers => true
  pod 'FirebaseCoreInternal', :modular_headers => true
  pod 'GoogleUtilities', :modular_headers => true
  pod 'react-native-google-maps', path: rn_maps_path
  
  pod 'react-native-branch', path: '../node_modules/react-native-branch'
  pod 'FirebaseAnalytics/WithoutAdIdSupport'

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

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

  # Enables Flipper.
  #
  # Note that if you have use_frameworks! enabled, Flipper will not work and
  # you should disable the next line.
  # use_flipper!()
  
  def configure_branch_settings(target)
    target.build_configurations.each do |config|
     config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = ['$(inherited)', 'BRANCH_EXCLUDE_IDFA_CODE=1']
    end
  end

  pre_install do |installer|
    Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}
  
    installer.pod_targets.each do |pod|
      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

  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|
      if target.name == 'Branch'
        configure_branch_settings(target)
      end
    end
    installer.pods_project.targets.each do |target|
      if target.name == 'RCT-Folly'
        target.build_configurations.each do |config|
          config.build_settings['HEADER_SEARCH_PATHS'] = "$(inherited) ${PODS_ROOT}/fmt/include"
        end
      end
    end
    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']
      end
      if target.name == 'react-native-google-maps'
        target.build_configurations.each do |config|
          config.build_settings['CLANG_ENABLE_MODULES'] = 'No'
        end
      end
      target.build_configurations.each do |config|
        if config.name != "Release"
          config.build_settings['DEVELOPMENT_TEAM'] = "XXXXXXXXXX"
        else
          config.build_settings['DEVELOPMENT_TEAM'] = "XXXXXXXXXX"
        end
      end
    end
  end
end

And my build log, error on line 11228:

/Users/david/Documents/iroomit/node_modules/react-native/ReactCommon/react/utils/RunLoopObserver.cpp:10:10: fatal error: 'react/debug/react_native_assert.h' file not found

Build 2023-07-06T13-56-37.txt

Alright, I figured it out. If anyone else has this issue, notice the pre_install directive in my Podfile:

pre_install do |installer|
    Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}
  
    installer.pod_targets.each do |pod|
      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

This is a workaround for static frameworks that used to be mentioned by the react-native-permissions package, but it looks like it's no longer required. After removing this as well as the individual permissions pods and updating the iOS permissions used in my package.json file as per the react-native-permissions README, we are back in business!

New Podfile:

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

$RNFirebaseAnalyticsWithoutAdIdSupport = true
$RNGoogleMobileAdsAsStaticFramework = true
platform :ios, min_ios_version_supported
prepare_react_native_project!

target 'roomi_app' do
  
  
  permissions_path = '../node_modules/react-native-permissions/ios'
  rn_maps_path = '../node_modules/react-native-maps'

  
  config = use_native_modules!

  flags = get_default_flags()
  
  use_frameworks! :linkage => :static

  pod 'react-native-maps', path: rn_maps_path
  pod 'GoogleMaps'
  pod 'FirebaseCoreExtension', :modular_headers => true
  pod 'FirebaseInstallations', :modular_headers => true
  pod 'GoogleDataTransport', :modular_headers => true
  pod 'nanopb', :modular_headers => true
  pod 'FirebaseCore', :modular_headers => true
  pod 'FirebaseCoreInternal', :modular_headers => true
  pod 'GoogleUtilities', :modular_headers => true
  pod 'react-native-google-maps', path: rn_maps_path
  
  pod 'react-native-branch', path: '../node_modules/react-native-branch'
  pod 'FirebaseAnalytics/WithoutAdIdSupport'

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

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

  # Enables Flipper.
  #
  # Note that if you have use_frameworks! enabled, Flipper will not work and
  # you should disable the next line.
  # use_flipper!()
  
  def configure_branch_settings(target)
    target.build_configurations.each do |config|
     config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = ['$(inherited)', 'BRANCH_EXCLUDE_IDFA_CODE=1']
    end
  end

  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|
      if target.name == 'Branch'
        configure_branch_settings(target)
      end
    end
    installer.pods_project.targets.each do |target|
      if target.name == 'RCT-Folly'
        target.build_configurations.each do |config|
          config.build_settings['HEADER_SEARCH_PATHS'] = "$(inherited) ${PODS_ROOT}/fmt/include"
        end
      end
    end
    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']
      end
      if target.name == 'react-native-google-maps'
        target.build_configurations.each do |config|
          config.build_settings['CLANG_ENABLE_MODULES'] = 'No'
        end
      end
      target.build_configurations.each do |config|
        if config.name != "Release"
          config.build_settings['DEVELOPMENT_TEAM'] = "XXXXXXXXXX"
        else
          config.build_settings['DEVELOPMENT_TEAM'] = "XXXXXXXXXX"
        end
      end
    end
  end
end

@harouf
Copy link

harouf commented Jul 7, 2023

@goguda I am also facing the same issue 'react/debug/react_native_assert.h' file not found. I am using yarn as well. So after upgrading react-native-permissions, did you still use the react-native patch file @evelant mentioned?

@goguda
Copy link

goguda commented Jul 7, 2023

@goguda I am also facing the same issue 'react/debug/react_native_assert.h' file not found. I am using yarn as well. So after upgrading react-native-permissions, did you still use the react-native patch file @evelant mentioned?

Nope no patch needed, worked as expected once I changed my Podfile and added iOS permissions to reactNativePermissionsIOS in my package.json as per the documentation.

@enchorb
Copy link

enchorb commented Jul 7, 2023

Applying the patch 58adc5e fixed it for me (using yarn)

kelset pushed a commit that referenced this issue Jul 10, 2023
Summary:
Fix build failure on iOS with pnpm and use_frameworks! due to cocoapods copying symlinked headers to wrong paths

When using pnpm all packages are symlinked to node_modules/.pnpm to prevent phantom dependency resolution. This causes react-native iOS build to fail because Cocoapods copies headers to incorrect destinations when they're behind symlinks. The fix resolves absolute paths to the header_mappings_dir at pod install time. With absolute paths cocoapods copies the headers correctly.

This commit also adds a few missing header search paths in use_frameworks! mode.

Fixes #38140

## Changelog:

<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

[IOS] [FIXED] - Build failure with pnpm and use_frameworks! due to incorrect header paths

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests

Pull Request resolved: #38158

Test Plan:
1. `pnpm pnpx react-native@latest init AwesomeProject`
2. `cd AwesomeProject`
3. `rm -rf node_modules yarn.lock`
4. `mkdir patches`
5. copy [react-native@0.72.1.patch](https://github.com/facebook/react-native/files/11937570/react-native%400.72.1.patch) to `patches/`
6. Add patch to package.json
```
"pnpm": {
    "patchedDependencies": {
        "react-native@0.72.1": "patches/react-native@0.72.1.patch"
    }
}
```
7. `pnpm install`
8. `cd ios`
9. `NO_FLIPPER=1 USE_FRAMEWORKS=static pod install`
10. `cd ..`
11. `pnpm react-native run-ios`

Hopefully an automated test of building with `pnpm` can be added to CI. I don't know how to make that happen, hopefully someone at facebook can do it.

Reviewed By: dmytrorykun

Differential Revision: D47211946

Pulled By: cipolleschi

fbshipit-source-id: 87640bd3f32f023c43291213b5291a7b990d7e1f
@maksibajo4
Copy link

I get the error: 'react/debug/react_native_assert.h' file not found, React-utils/RunLoopObserver.
This 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, '13.0'
prepare_react_native_project!

flipper_config = ENV['NO_FLIPPER'] == "1" ? FlipperConfiguration.disabled : FlipperConfiguration.enabled


dynamic_frameworks = [
    'Starscream',
    'iProov',
    'DatadogSDK',
    'SwiftProtobuf',
]
pre_install do |installer|
  installer.pod_targets.each do |pod|
    if !dynamic_frameworks.include?(pod.name)
      puts "Overriding the static_framework? method for #{pod.name}"
      def pod.static_framework?;
        true
      end
      def pod.build_type;
        Pod::BuildType.static_library
      end
    end
  end
end

target 'POK' do
  use_frameworks! :linkage => :static
  config = use_native_modules!
  flags = get_default_flags()

  use_react_native!(
    :path => config[:reactNativePath],
    :hermes_enabled => true,
    :fabric_enabled => flags[:fabric_enabled],
    :flipper_configuration => FlipperConfiguration.disabled,
    :app_path => "#{Pod::Config.instance.installation_root}/.."
  )
  
  permissions_path = '../node_modules/react-native-permissions/ios'
  pod 'Permission-Camera', :path => "#{permissions_path}/Camera"
  pod 'Permission-Contacts', :path => "#{permissions_path}/Contacts"
  pod 'Permission-Notifications', :path => "#{permissions_path}/Notifications"
  pod 'Google-Maps-iOS-Utils', :git => 'https://github.com/Simon-TechForm/google-maps-ios-utils.git', :branch => 'feat/support-apple-silicon'
  pod 'SRSRadialGradient', :path => '../node_modules/react-native-radial-gradient/ios'
  pod 'FirebaseCoreExtension', :modular_headers => true
  pod 'FirebaseInstallations', :modular_headers => true
  pod 'GoogleDataTransport', :modular_headers => true
  pod 'nanopb', :modular_headers => true
  pod 'FirebaseCore', :modular_headers => true
  pod 'FirebaseCoreInternal', :modular_headers => true
  pod 'GoogleUtilities', :modular_headers => true
  $RNFirebaseAsStaticFramework = true

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

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

  post_install do |installer|
      installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
          config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
        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'] = '12.0'
          end
        end
      end
      `sed -i -e  $'s/__IPHONE_10_0/__IPHONE_13_0/' #{installer.sandbox.root}/RCT-Folly/folly/portability/Time.h`
      path = "Pods/Target Support Files/Pods-POK/Pods-POK-frameworks.sh"
      lines = File.readlines(path)
      lines.insert(177, 'install_framework "${PODS_XCFRAMEWORKS_BUILD_DIR}/hermes-engine/hermes.framework"'+"\n")
      File.write(path, lines.join, mode: "w")
  end
end

Kudo pushed a commit to expo/react-native that referenced this issue Jul 11, 2023
Summary:
Fix build failure on iOS with pnpm and use_frameworks! due to cocoapods copying symlinked headers to wrong paths

When using pnpm all packages are symlinked to node_modules/.pnpm to prevent phantom dependency resolution. This causes react-native iOS build to fail because Cocoapods copies headers to incorrect destinations when they're behind symlinks. The fix resolves absolute paths to the header_mappings_dir at pod install time. With absolute paths cocoapods copies the headers correctly.

This commit also adds a few missing header search paths in use_frameworks! mode.

Fixes facebook#38140

## Changelog:

<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

[IOS] [FIXED] - Build failure with pnpm and use_frameworks! due to incorrect header paths

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests

Pull Request resolved: facebook#38158

Test Plan:
1. `pnpm pnpx react-native@latest init AwesomeProject`
2. `cd AwesomeProject`
3. `rm -rf node_modules yarn.lock`
4. `mkdir patches`
5. copy [react-native@0.72.1.patch](https://github.com/facebook/react-native/files/11937570/react-native%400.72.1.patch) to `patches/`
6. Add patch to package.json
```
"pnpm": {
    "patchedDependencies": {
        "react-native@0.72.1": "patches/react-native@0.72.1.patch"
    }
}
```
7. `pnpm install`
8. `cd ios`
9. `NO_FLIPPER=1 USE_FRAMEWORKS=static pod install`
10. `cd ..`
11. `pnpm react-native run-ios`

Hopefully an automated test of building with `pnpm` can be added to CI. I don't know how to make that happen, hopefully someone at facebook can do it.

Reviewed By: dmytrorykun

Differential Revision: D47211946

Pulled By: cipolleschi

fbshipit-source-id: 87640bd3f32f023c43291213b5291a7b990d7e1f
@billnbell
Copy link
Contributor

I have a PR for adding 2 more to the search path can you take a look? @evelant

#38247

@goguda
Copy link

goguda commented Jul 20, 2023

I get the error: 'react/debug/react_native_assert.h' file not found, React-utils/RunLoopObserver. This 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, '13.0'
prepare_react_native_project!

flipper_config = ENV['NO_FLIPPER'] == "1" ? FlipperConfiguration.disabled : FlipperConfiguration.enabled


dynamic_frameworks = [
    'Starscream',
    'iProov',
    'DatadogSDK',
    'SwiftProtobuf',
]
pre_install do |installer|
  installer.pod_targets.each do |pod|
    if !dynamic_frameworks.include?(pod.name)
      puts "Overriding the static_framework? method for #{pod.name}"
      def pod.static_framework?;
        true
      end
      def pod.build_type;
        Pod::BuildType.static_library
      end
    end
  end
end

target 'POK' do
  use_frameworks! :linkage => :static
  config = use_native_modules!
  flags = get_default_flags()

  use_react_native!(
    :path => config[:reactNativePath],
    :hermes_enabled => true,
    :fabric_enabled => flags[:fabric_enabled],
    :flipper_configuration => FlipperConfiguration.disabled,
    :app_path => "#{Pod::Config.instance.installation_root}/.."
  )
  
  permissions_path = '../node_modules/react-native-permissions/ios'
  pod 'Permission-Camera', :path => "#{permissions_path}/Camera"
  pod 'Permission-Contacts', :path => "#{permissions_path}/Contacts"
  pod 'Permission-Notifications', :path => "#{permissions_path}/Notifications"
  pod 'Google-Maps-iOS-Utils', :git => 'https://github.com/Simon-TechForm/google-maps-ios-utils.git', :branch => 'feat/support-apple-silicon'
  pod 'SRSRadialGradient', :path => '../node_modules/react-native-radial-gradient/ios'
  pod 'FirebaseCoreExtension', :modular_headers => true
  pod 'FirebaseInstallations', :modular_headers => true
  pod 'GoogleDataTransport', :modular_headers => true
  pod 'nanopb', :modular_headers => true
  pod 'FirebaseCore', :modular_headers => true
  pod 'FirebaseCoreInternal', :modular_headers => true
  pod 'GoogleUtilities', :modular_headers => true
  $RNFirebaseAsStaticFramework = true

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

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

  post_install do |installer|
      installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
          config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
        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'] = '12.0'
          end
        end
      end
      `sed -i -e  $'s/__IPHONE_10_0/__IPHONE_13_0/' #{installer.sandbox.root}/RCT-Folly/folly/portability/Time.h`
      path = "Pods/Target Support Files/Pods-POK/Pods-POK-frameworks.sh"
      lines = File.readlines(path)
      lines.insert(177, 'install_framework "${PODS_XCFRAMEWORKS_BUILD_DIR}/hermes-engine/hermes.framework"'+"\n")
      File.write(path, lines.join, mode: "w")
  end
end

You're using react-native-permissions the old way like I was. Try the fix I posted above^

@harouf
Copy link

harouf commented Jul 20, 2023

@maksibajo4 Did you fix the build issue you faced? I am also facing the same issue as I also have some dynamic frameworks (iProov) to be exempted from being converted to static library.

@harouf
Copy link

harouf commented Jul 20, 2023

@goguda the issue is basically due to this part and updating the integration of RN permissions doesn't help.

   def pod.static_framework?;
          true
        end
        def pod.build_type;
          Pod::BuildType.static_library
        end

@Vrunalbenke
Copy link

Vrunalbenke commented Mar 18, 2024

@goguda i am getting this error, i am using npm
node_modules/react-native/ReactCommon/react/utils/RunLoopObserver.cpp:10:10: 'react/debug/react_native_assert.h' file not found

this 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

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

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

platform :ios, '13.4'
node_require('react-native/scripts/react_native_pods.rb')
node_require('react-native-permissions/scripts/setup.rb')
prepare_react_native_project!


setup_permissions([
  'LocationAccuracy',
  'LocationAlways',
  'LocationWhenInUse',
])

permissions_path = '../node_modules/react-native-permissions/ios'
pod 'Permission-Camera', :path => "#{permissions_path}/Camera"
# 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 'vendit' do
  config = use_native_modules!

  rn_maps_path = '../node_modules/react-native-maps'
  pod 'react-native-google-maps', :path => rn_maps_path
  pod 'GoogleMaps', '7.4.0' # <<<<---- I added the '5.1.0' version here
  pod 'Google-Maps-iOS-Utils', '4.2.2' 
  # Flags change depending on the env values.
  flags = get_default_flags()
  use_frameworks! :linkage => :static
  $RNFirebaseAsStaticFramework = true
  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}/.."
  )

  # use_flipper!
  # post_install do |installer|
  #   flipper_post_install(installer)

  #   installer.pods_project.targets.each do |target|
  #     if target.name == "React-Core-AccessibilityResources"
  #       target.remove_from_project
  #     end
  #   end
  # end

  target 'venditTests' 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)
  end
end

and package.json file

{
  "name": "vendit",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "lint": "eslint .",
    "start": "react-native start",
    "test": "jest",
    "android-clean": "cd android && gradlew clean && gradlew :app:bundleRelease",
    "build-apk": "react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/build/intermediates/res/merged/release/ && rm -rf android/app/src/main/res/drawable-* && rm -rf android/app/src/main/res/raw/* && cd android && ./gradlew assembleRelease && cd ..",
    "build-debug-apk": "react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/build/intermediates/res/merged/debug/ && rm -rf android/app/src/main/res/drawable-* && rm -rf android/app/src/main/res/raw/* && cd android && gradlew assembleDebug && cd ..",
    "iLegacy": "npm i --legacy-peer-deps"
  },
  "dependencies": {
    "@gorhom/bottom-sheet": "^4.5.1",
    "@notifee/react-native": "^7.8.2",
    "@react-native-async-storage/async-storage": "^1.19.3",
    "@react-native-community/blur": "^4.3.2",
    "@react-native-community/cli-platform-android": "^11.3.8",
    "@react-native-community/datetimepicker": "^7.6.0",
    "@react-native-community/netinfo": "^9.4.1",
    "@react-native-firebase/app": "^18.9.0",
    "@react-native-firebase/dynamic-links": "^18.9.0",
    "@react-native-firebase/messaging": "^18.9.0",
    "@react-native-masked-view/masked-view": "^0.2.9",
    "@react-navigation/bottom-tabs": "^6.5.9",
    "@react-navigation/elements": "^1.3.19",
    "@react-navigation/material-top-tabs": "^6.6.12",
    "@react-navigation/native": "^6.1.8",
    "@react-navigation/native-stack": "^6.9.14",
    "@reduxjs/toolkit": "^1.9.6",
    "axios": "^1.5.1",
    "base64-js": "^1.5.1",
    "deprecated-react-native-prop-types": "^5.0.0",
    "i18next": "^23.5.1",
    "lottie-ios": "^4.4.0",
    "lottie-react-native": "^6.6.0",
    "patch-package": "^8.0.0",
    "react": "18.2.0",
    "react-i18next": "^13.2.2",
    "react-native": "0.72.5",
    "react-native-asset": "^2.1.1",
    "react-native-camera": "^4.2.1",
    "react-native-country-picker-modal": "^2.0.0",
    "react-native-geolocation-service": "^5.3.1",
    "react-native-gesture-handler": "^2.13.1",
    "react-native-keyboard-aware-scroll-view": "^0.9.5",
    "react-native-linear-gradient": "^2.8.3",
    "react-native-maps": "^1.7.1",
    "react-native-modal": "^13.0.1",
    "react-native-modal-popover": "^2.1.3",
    "react-native-navigation-bar-color": "^2.0.2",
    "react-native-pager-view": "^6.2.1",
    "react-native-permissions": "^3.10.1",
    "react-native-popup-menu": "^0.16.1",
    "react-native-qrcode-scanner": "^1.5.5",
    "react-native-qrcode-svg": "^6.3.0",
    "react-native-reanimated": "^3.7.2",
    "react-native-safe-area-context": "^4.7.2",
    "react-native-screens": "^3.25.0",
    "react-native-share": "^10.0.2",
    "react-native-shimmer-placeholder": "^2.0.9",
    "react-native-splash-screen": "^3.3.0",
    "react-native-svg": "^13.14.0",
    "react-native-svg-transformer": "^1.1.0",
    "react-native-tab-view": "^3.5.2",
    "react-native-toast-message": "^2.1.6",
    "react-native-vector-icons": "^10.0.1",
    "react-native-webview": "^13.7.0",
    "react-native-wheel-pick": "^1.2.2",
    "react-redux": "^8.1.2",
    "redux": "^4.2.1",
    "rn-fetch-blob": "^0.12.0"
  },
  "devDependencies": {
    "@babel/core": "^7.20.0",
    "@babel/preset-env": "^7.20.0",
    "@babel/runtime": "^7.20.0",
    "@react-native/eslint-config": "^0.72.2",
    "@react-native/metro-config": "^0.72.11",
    "babel-jest": "^29.2.1",
    "babel-plugin-module-resolver": "^5.0.0",
    "eslint": "^8.19.0",
    "jest": "^29.2.1",
    "metro-react-native-babel-preset": "0.76.8",
    "prettier": "^2.4.1",
    "react-test-renderer": "18.2.0"
  },
  "engines": {
    "node": ">=16"
  },
  "resolutions": {
    "react-native-permissions": "^3.8.0"
  },
  "overrides": {
    "react-native-qrcode-scanner": {
      "react-native-permissions": "^3.8.0"
    }
  }
}

Started getting this error after firebase messaging setup

@Djotchuang
Copy link

For me, I was placing this line of code:
rn_maps_path = '../node_modules/react-native-maps'
pod 'react-native-google-maps', :path => rn_maps_path

above
target 'commutebuddy' do
config = use_native_modules!

It was supposed to be inside.

@hoangf-mmj
Copy link

hoangf-mmj commented Dec 20, 2024

I facing this issue, the error occurs when using use_frameworks! :linkage => :static in combination with pnpm. I tried two solutions :

Solution 1: Switch to npm or yarn
The easiest solution is to switch to npm or yarn instead of pnpm. However, this approach should be avoided in monorepos where it's important to use the same package manager across the entire repository. => not my choice

Solution 2: Avoid use_frameworks! :linkage => :static and Set Up Manually
Instead of using use_frameworks! :linkage => :static, I manually configure the setup. For example, to set up Firebase, follow the official documentation here:
Firebase iOS Installation Guide.

After manual setup, I encounter errors regarding missing packages. To fix this, simply add the required dependencies to my Podfile. For Firebase, I add the following:

 pod 'GoogleUtilities', :modular_headers => true # Add missing package
 pod 'FirebaseCore', :modular_headers => true    # Add missing package
 pod 'RNFBApp', :path => '../node_modules/@react-native-firebase/app' # Firebase manual setup

By following these steps, I was able to successfully set up Firebase Cloud Messaging (FCM) without further errors.

I also noticed a pull request addressing this issue—hopefully, it will be merged soon, and we won't need to apply this manual fix anymore.

Here is my environment for reference:

   "react": "18.3.1",
   "react-native": "0.76.2",
   "@react-native-firebase/app": "^21.6.1",
   "@react-native-firebase/messaging": "^21.6.1",

I use monorepo with pnpm:
./

node_module
package.json
pnpm-workspace.yaml
packages

react-native-app (use FCM)

node_module
package.json
ios

podfile

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!

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 'StudentMobileApp' do
  config = use_native_modules!
  $RNFirebaseAsStaticFramework = true

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

  pod 'GoogleUtilities', :modular_headers => true
  pod 'FirebaseCore', :modular_headers => true
  pod 'RNFBApp', :path => '../node_modules/@react-native-firebase/app'

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

@DaniloMladenovic
Copy link

DaniloMladenovic commented Jan 15, 2025

Adding:
pod 'GoogleUtilities', :modular_headers => true # Add missing package
pod 'FirebaseCore', :modular_headers => true # Add missing package
pod 'RNFBApp', :path => '../node_modules/@react-native-firebase/app' # Firebase manual setup

instead of use_frameworks! :linkage => :static helped me.

@pakerwreah
Copy link

Thanks @DaniloMladenovic 🙏🏻
I added this to my expo plugins and it worked like a charm ✨

[
  'expo-build-properties',
  {
    ios: {
      // Firebase fix
      extraPods: ['GoogleUtilities', 'FirebaseCore'].map((podName) => ({
        name: podName,
        modular_headers: true,
      })),
    },
  },
]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Impact: Regression Describes a behavior that used to work on a prior release, but stopped working recently. Needs: Triage 🔍 Platform: iOS iOS applications. Type: Upgrade Issue Issues reported from upgrade issue form
Projects
None yet
Development

Successfully merging a pull request may close this issue.