Skip to content

New Architecture - Builds fail when Podfile uses static linking #8026

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

Open
1 task done
kevin-madden-gf opened this issue May 20, 2025 · 7 comments
Open
1 task done

Comments

@kevin-madden-gf
Copy link

kevin-madden-gf commented May 20, 2025

What happened?

When using static frameworks in the Podfile:

Use static frameworks

use_frameworks! :linkage => :static

Build fail with an error in RNNButtonView (RCTHost.h file not found) - see the image from Xcode below:

Image

Static linking is required for some packages, e.g. react-native-firebase.

This seems to have something to do with the builds that support new architecture. Build 8.0.0 with new architecture disabled builds fine.

What was the expected behaviour?

The build completes without issue.

Was it tested on latest react-native-navigation?

  • I have tested this issue on the latest react-native-navigation release and it still reproduces.

Help us reproduce this issue!

Try using a Podfile like the one below, on 8.1.0 RC1, to replicate

$RNFirebaseAsStaticFramework = true
# 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, '15.1'
prepare_react_native_project!

# Use static frameworks
use_frameworks! :linkage => :static

config = use_native_modules!

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 'AwesomeProject' do
  ENV['RCT_NEW_ARCH_ENABLED'] = '1'

  use_react_native!(
    :path => config[:reactNativePath],
    # An absolute path to your application root.
    :app_path => "#{Pod::Config.instance.installation_root}/..",
    :hermes_enabled => true
  )
  
    pod 'Firebase', :modular_headers => true
    pod 'FirebaseCore', :modular_headers => true
    pod 'FirebaseCoreInternal', :modular_headers => true
    pod 'GoogleUtilities', :modular_headers => true

  target 'AwesomeProjectTests' 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

In what environment did this happen?

React Native Navigation version: 8.1.0 RC1
React Native version: 0.76.9
Has Fabric (React Native's new rendering system) enabled: (yes/no) yes
Node version: 22
Device model: iPhone 11
iOS version: 18.1

@ivosw
Copy link

ivosw commented May 21, 2025

My build fails at different point but this bit is working. I have this line use_frameworks! :linkage => :static completely removed. What I have instead is $RNFirebaseAsStaticFramework = true. It sits below modular headers.

pod 'Firebase', :modular_headers => true
pod 'FirebaseCore', :modular_headers => true
pod 'FirebaseCoreInternal', :modular_headers => true
pod 'GoogleUtilities', :modular_headers => true
$RNFirebaseAsStaticFramework = true

@batuctn
Copy link

batuctn commented May 23, 2025

My build fails at different point but this bit is working. I have this line use_frameworks! :linkage => :static completely removed. What I have instead is $RNFirebaseAsStaticFramework = true. It sits below modular headers.

pod 'Firebase', :modular_headers => true
pod 'FirebaseCore', :modular_headers => true
pod 'FirebaseCoreInternal', :modular_headers => true
pod 'GoogleUtilities', :modular_headers => true
$RNFirebaseAsStaticFramework = true

Thanks for the update. After applying this change, the build failure issue was resolved. However, now the app gets stuck on the splash screen. I checked the logs in Xcode, but I couldn't identify a clear reason for the issue. Let me know if you have any suggestions or if there's anything specific I should look into. @ivosw @kevin-madden-gf

@manuhook
Copy link

for Firebase you must you must use use_frameworks! :linkage => :static, anyone that uses modular_headers stuff in their Podfile is going to have compilation problems invertase/react-native-firebase#8271 (comment)

@batuctn
Copy link

batuctn commented May 29, 2025

for Firebase you must you must use use_frameworks! :linkage => :static, anyone that uses modular_headers stuff in their Podfile is going to have compilation problems invertase/react-native-firebase#8271 (comment)

@manuhook I applied use_frameworks! :linkage => :static and removed all modular_headers. But now I’m getting the same RCTHost.h file not found error mentioned earlier. Any ideas how to fix this without reverting changes?

@manuhook
Copy link

for Firebase you must you must use use_frameworks! :linkage => :static, anyone that uses modular_headers stuff in their Podfile is going to have compilation problems invertase/react-native-firebase#8271 (comment)

@manuhook I applied use_frameworks! :linkage => :static and removed all modular_headers. But now I’m getting the same RCTHost.h file not found error mentioned earlier. Any ideas how to fix this without reverting changes?

I have the same error, I didn't find a solution for the moment :(

@manuhook
Copy link

manuhook commented Jun 2, 2025

I think I’ve resolved the errors related to

use_frameworks! :linkage => :static

Tested with RNN 8.0.0 and React Native 0.76.7 - New Arch enabled.

You need to modify the ReactNativeNavigation.podspec file as follows:

require 'json'

package = JSON.parse(File.read(File.join(__dir__, 'package.json')))

fabric_enabled = ENV['RCT_NEW_ARCH_ENABLED'] == '1'

Pod::Spec.new do |s|
  s.name         = "ReactNativeNavigation"
  s.version      = package['version']
  s.summary      = package['description']

  s.authors      = "Wix.com"
  s.homepage     = package['homepage']
  s.license      = package['license']
  s.platform     = :ios, "11.0"

  s.module_name  = 'ReactNativeNavigation'
  s.default_subspec = 'Core'

  s.subspec 'Core' do |ss|
    s.source              = { :git => "https://github.com/wix/react-native-navigation.git", :tag => "#{s.version}" }
    s.source_files    = 'lib/ios/**/*.{h,m,mm,cpp}'
    s.exclude_files       = "lib/ios/ReactNativeNavigationTests/**/*.*", "lib/ios/OCMock/**/*.*"
  end

  if fabric_enabled
    install_modules_dependencies(s)

    folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -DFOLLY_CFG_NO_COROUTINES=1 -Wno-comma -Wno-shorten-64-to-32'
    fabric_flags = fabric_enabled ? '-DRCT_NEW_ARCH_ENABLED' : ''
    header_search_paths = [
      '"$(PODS_ROOT)/Headers/Private/React-Core"', # as React-RCTAppDelegate.podspec to access JSCExecutorFactory.h
      '"$(PODS_ROOT)/boost"',
      '"$(PODS_ROOT)/boost-for-react-native"',
      '"$(PODS_ROOT)/RCT-Folly"',
      '"$(PODS_ROOT)/Headers/Private/Yoga"',
      '"${PODS_CONFIGURATION_BUILD_DIR}/React-jsinspector/jsinspector_modern.framework/Headers"',
    ]
    if fabric_enabled
      header_search_paths.concat([
        # [begin] transitive dependencies of React-RCTAppDelegate that are not defined modules
        '"${PODS_CONFIGURATION_BUILD_DIR}/React-RuntimeApple/React_RuntimeApple.framework/Headers"',
        '"${PODS_CONFIGURATION_BUILD_DIR}/React-RuntimeCore/React_RuntimeCore.framework/Headers"',
        '"${PODS_CONFIGURATION_BUILD_DIR}/React-jserrorhandler/React_jserrorhandler.framework/Headers"',
        '"${PODS_CONFIGURATION_BUILD_DIR}/React-runtimescheduler/React_runtimescheduler.framework/Headers"',
        '"${PODS_CONFIGURATION_BUILD_DIR}/React-utils/React_utils.framework/Headers"',
        '"${PODS_CONFIGURATION_BUILD_DIR}/React-debug/React_debug.framework/Headers"',
        '"${PODS_CONFIGURATION_BUILD_DIR}/React-rendererdebug/React_rendererdebug.framework/Headers"',
        '"${PODS_CONFIGURATION_BUILD_DIR}/React-nativeconfig/React_nativeconfig.framework/Headers"',
        '"${PODS_CONFIGURATION_BUILD_DIR}/React-RCTAppDelegate/React_RCTAppDelegate.framework/Headers"',
        '"${PODS_CONFIGURATION_BUILD_DIR}/React-performancetimeline/React_performancetimeline.framework/Headers"',
        '"${PODS_CONFIGURATION_BUILD_DIR}/React-rendererconsistency/React_rendererconsistency.framework/Headers"',
        # [end] transitive dependencies of React-RCTAppDelegate that are not defined modules
      ])
    end
    s.pod_target_xcconfig = {
      'HEADER_SEARCH_PATHS' => header_search_paths.join(' '),
      "CLANG_CXX_LANGUAGE_STANDARD" => "c++17",
      "OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
    }

    s.compiler_flags  = folly_compiler_flags + ' ' + '-DRCT_NEW_ARCH_ENABLED'
    s.requires_arc    = true

    s.dependency "React"
    s.dependency "React-Core"
    s.dependency "React-RCTFabric"
    s.dependency "React-cxxreact"
    s.dependency "React-Fabric"
    s.dependency "React-Codegen"
    s.dependency "RCT-Folly"
    s.dependency "RCTRequired"
    s.dependency "RCTTypeSafety"
    s.dependency "ReactCommon/turbomodule/core"
    s.dependency "React-runtimeexecutor"
    s.dependency "React-rncore"
  end

  s.dependency 'React-Core'
  s.dependency 'React-CoreModules'
  s.dependency 'React-RCTImage'
  s.dependency 'React-RCTText'
  s.dependency 'HMSegmentedControl'
  s.frameworks = 'UIKit'
end

Now I have this error but I believe it's not linked to use_frameworks! :linkage => :static
#7980

@lichstam
Copy link

lichstam commented Jun 6, 2025

Could anyone with knowledge about this issue point us in a direction? My understanding is that the imports/headers need to be resolved somehow for the New Architecture + static linking combination?

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

No branches or pull requests

5 participants