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

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

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 4
  • Comments: 24 (4 by maintainers)

Commits related to this issue

Most upvoted comments

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

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

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