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

[🐛] Adding use_framworks! gives transitive dependencies include statically linked binaries error #6425

Closed
1 of 10 tasks
KrisLau opened this issue Jul 27, 2022 · 29 comments
Closed
1 of 10 tasks
Labels
help: needs-triage Issue needs additional investigation/triaging. type: bug New bug report

Comments

@KrisLau
Copy link

KrisLau commented Jul 27, 2022

Issue

So reading through the Altering CocoaPods to use frameworks section of the documentation, I see the note about use_frameworks!. However now that the React Native v0.69.1 has been released, how do we go about modifying the podfile?

Googling surfaces this: facebook/flipper#606 (comment) and I'm wondering if this is the way to go or if there is another recommended way? I'm on react native v0.69.3 now


Project Files

N/A

Javascript

N/A

package.json:

# N/A

firebase.json for react-native-firebase v6:

# N/A

iOS

Click To Expand

ios/Podfile:

  • I'm not using Pods
  • I'm using Pods and my Podfile looks like:
require File.join(File.dirname(`node --print "require.resolve('expo/package.json')"`), "scripts/autolinking")
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, '13.0'
 install! 'cocoapods', :deterministic_uuids => false
 production = ENV["PRODUCTION"] == "1"

target 'Prototype' do
   use_frameworks!
   use_expo_modules!
   post_integrate do |installer|
     begin
       expo_patch_react_imports!(installer)
     rescue => e
       Pod::UI.warn e
     end
   end
   config = use_native_modules!

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

   use_react_native!(
     :path => config[:reactNativePath],
     # to enable hermes on iOS, change `false` to `true` and then install pods
     :production => production,
     :hermes_enabled => flags[:hermes_enabled],
     :fabric_enabled => flags[:fabric_enabled],
     :flipper_configuration => FlipperConfiguration.enabled,
     # An absolute path to your application root.
     :app_path => "#{Pod::Config.instance.installation_root}/.."
   )

  # NOTE: Do not remove, needed to keep WatermelonDB compiling:
  pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi', :modular_headers => true

  # NOTE: This is required as of v0.23
  pod 'simdjson', path: '../node_modules/@nozbe/simdjson'

  target 'PrototypeTests' 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!({'Flipper' => '0.75.1', 'Flipper-Folly' => '2.5.3', 'Flipper-RSocket' => '1.3.1'})

  post_install do |installer|
    react_native_post_install(installer)
    __apply_Xcode_12_5_M1_post_install_workaround(installer)
  end
end

AppDelegate.m:

// N/A


Android

Click To Expand

Have you converted to AndroidX?

  • my application is an AndroidX application?
  • I am using android/gradle.settings jetifier=true for Android compatibility?
  • I am using the NPM package jetifier for react-native compatibility?

android/build.gradle:

// N/A

android/app/build.gradle:

// N/A

android/settings.gradle:

// N/A

MainApplication.java:

// N/A

AndroidManifest.xml:

<!-- N/A -->


Environment

Click To Expand

react-native info output:

 OUTPUT GOES HERE
  • Platform that you're experiencing the issue on:
    • iOS
    • Android
    • iOS but have not tested behavior on Android
    • Android but have not tested behavior on iOS
    • Both
  • react-native-firebase version you're using that has this issue:
    • e.g. 5.4.3
  • Firebase module(s) you're using that has the issue:
    • e.g. Instance ID
  • Are you using TypeScript?
    • Y/N & VERSION


@KrisLau KrisLau added help: needs-triage Issue needs additional investigation/triaging. type: bug New bug report labels Jul 27, 2022
@NicolasTA-webagency
Copy link

Hi !

Try this : #6412 (comment)

@mikehardy
Copy link
Collaborator

Duplicate of #6332 and please note - before you do any workarounds - this particular comment:

#6332 (comment)

In particular, if you want to use react-native-firebase v15+ you must use use_frameworks and for now Flipper is not compatible with that so you must not use Flipper. If that's important to you and your business I think it's an area that needs help so you might help by digging in to the underlying issues and getting fixes through

@KrisLau
Copy link
Author

KrisLau commented Aug 4, 2022

@mikehardy Sorry if this is out of scope but is flipper used automatically/depended on by React native like will removing it change anything about my usual workflow with React native? I've always seen it in my podfile but i wasn't sure exactly what purpose it serves? I know it's a debugger but I'm not sure if that means React native will stop displaying stack traces if I remove it. Sorry if this is a dumb question haha

@KrisLau
Copy link
Author

KrisLau commented Aug 4, 2022

@mikehardy Also to disable do I just remove the :flipper_configuration or change it to :flipper_configuration => FlipperConfiguration.disabled?

require File.join(File.dirname(`node --print "require.resolve('expo/package.json')"`), "scripts/autolinking")
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, '13.0'
 install! 'cocoapods', :deterministic_uuids => false
 production = ENV["PRODUCTION"] == "1"

target 'Prototype' do
   use_frameworks! # For RNFirebase
   use_expo_modules!
   post_integrate do |installer|
    begin
      expo_patch_react_imports!(installer)
    rescue => e
      Pod::UI.warn e
    end
     begin
       expo_patch_react_imports!(installer)
     rescue => e
       Pod::UI.warn e
     end
   end
   config = use_native_modules!

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

   use_react_native!(
     :path => config[:reactNativePath],
     # to enable hermes on iOS, change `false` to `true` and then install pods
     :production => production,
     :hermes_enabled => flags[:hermes_enabled],
     :fabric_enabled => flags[:fabric_enabled],
     :flipper_configuration => FlipperConfiguration.enabled,  // this one?
     # An absolute path to your application root.
     :app_path => "#{Pod::Config.instance.installation_root}/.."
   )

  # NOTE: Do not remove, needed to keep WatermelonDB compiling:
  pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi', :modular_headers => true

  # NOTE: This is required as of v0.23
  pod 'simdjson', path: '../node_modules/@nozbe/simdjson'

  target 'PrototypeTests' 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!({'Flipper' => '0.75.1', 'Flipper-Folly' => '2.5.3', 'Flipper-RSocket' => '1.3.1'})

  post_install do |installer|
    react_native_post_install(installer)
    __apply_Xcode_12_5_M1_post_install_workaround(installer)
  end
end

Also in the docs, is $RNFirebaseAsStaticFramework = true required for the latest version or optional? Would you recommend upgrading to react-native 0.69 or to 0.68.2? Also related to that same docs, I think the hermes problem was resolved in 0.69.3

#6332 (comment)

Does the :modular_headers workaround not work?

@samuelhulla
Copy link

samuelhulla commented Aug 8, 2022

Good news everyone. Just couple of minutes ago react-native: 0.69.4 was released.

The only thing that's still not compatible is Flipper.

So my podfile has the following changes:

target 'YourAppName' do
  use_frameworks!
  $RNFirebaseAsStaticFramework = true

and I removed the following line:

:flipper_configuration => FlipperConfiguration.enabled,

as of note (which was particularly problematic before). The app still works with hermes and fabric so this is pretty huge!

@FadiAboMsalam
Copy link

@samuelhulla did you manage to make it work with flipper_configuration enabled ?

@Y-k-Y
Copy link

Y-k-Y commented Aug 19, 2022

@FadiAboMsalam as @mikehardy noted you can't use Flipper with use_frameworks! which is necessary on firebase. I don't think there is workaround to use Flipper at this time. Maybe you should downgrade firebase if Flipper is important to your work.

@mikehardy
Copy link
Collaborator

I'm just getting back to this from a bunch of travel, sorry I've been absent.

Hermes will work with use_frameworks! :linkage => :static (the static part is important!

Flipper will not work. Disabling it only means you can't use Flipper. Everything else is normal. If you don't explicitly use Flipper, you won't notice. Setting it to FlipperConfiguration.disabled does the trick

Still working on Flipper just so it can work, but having Hermes working is great progress

@mikehardy
Copy link
Collaborator

I've just learned of this (I should have seen it earlier!) which will be my first attempt at getting it working for Flipper. It will likely still be a few days, if anyone else wants to try it and report, it seems pretty easy as just a Podfile change:

https://fbflipper.com/docs/getting-started/ios-native/#cocoapods

(note specifically the use_frameworks commented out section, that's the thing to try)

@wfern
Copy link

wfern commented Aug 24, 2022

I've just learned of this (I should have seen it earlier!) which will be my first attempt at getting it working for Flipper. It will likely still be a few days, if anyone else wants to try it and report, it seems pretty easy as just a Podfile change:

https://fbflipper.com/docs/getting-started/ios-native/#cocoapods

(note specifically the use_frameworks commented out section, that's the thing to try)

Hey @mikehardy, I tried it but can't pass from these errors:

Undefined symbol: google::ErrnoLogMessage::ErrnoLogMessage(char const*, int, int, long long, void (google::LogMessage::*)())

Undefined symbol: google::InitVLOG3__(google::SiteFlag*, int*, char const*, int)

An issue related: facebook/flipper#3861 but instead of x86_64, for me it is arm64 (m1).

At least for now I can successfully build with use_frameworks (static) and hermes but no luck with Flipper.


Another thing is, to build successfully without Flipper I have to set FlipperConfiguration.disabled on the Podfile and then set

react-native-flipper': {
      platforms: {
        ios: null,
      },
    },

on react-native.config.js, if not I get the following error:

.../node_modules/react-native-flipper/ios/FlipperReactNativeJavaScriptPluginManager.h:12:9: 'FlipperKit/FlipperClient.h' file not found

Related to that I found these issues: facebook/flipper#3995 and jakobo/expo-community-flipper#18

I will try to dig a bit more into this problem.

@mikehardy
Copy link
Collaborator

mikehardy commented Aug 24, 2022

Oh I had high hopes for the trick from the Flipper documentation. I guess it will take more serious effort

Thanks a bunch for testing, by the way

For your second one it, I personally do not have react-native-flipper installed. Are you using flipper for Android then? I wouldn't expect that package to work with Flipper disabled so it makes sense that with Flipper disabled on iOS you have to tell react-native-flipper not to try anything on iOS

@wfern
Copy link

wfern commented Aug 24, 2022

Yes, I use it on Android.

I swore that package "react-native-flipper" was mandatory, but now I know it's only necessary when using third party flipper plugins like react-navigation and redux plugin in Flipper.

I tested again without the the "react-native-flipper" package but got the same error:

Undefined symbols for architecture arm64:
  "google::ErrnoLogMessage::ErrnoLogMessage(char const*, int, int, long long, void (google::LogMessage::*)())", referenced from:
      folly::(anonymous namespace)::readRandomDevice(void*, unsigned long) in libFlipper-Folly.a(Random.o)
      folly::fibers::StackCache::borrow(unsigned long) in libFlipper-Folly.a(GuardPageAllocator.o)
      folly::fibers::StackCache::StackCache(unsigned long, unsigned long) in libFlipper-Folly.a(GuardPageAllocator.o)
      folly::fibers::StackCache::~StackCache() in libFlipper-Folly.a(GuardPageAllocator.o)
      folly::ssl::OpenSSLUtils::getPeerAddressFromX509StoreCtx(x509_store_ctx_st*, sockaddr_storage*, unsigned int*) in libFlipper-Folly.a(OpenSSLUtils.o)
  "google::InitVLOG3__(google::SiteFlag*, int*, char const*, int)", referenced from:
      folly::EventBase::~EventBase() in libFlipper-Folly.a(EventBase.o)
      folly::EventBase::SmoothLoopTime::setTimeInterval(std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000l> >) in libFlipper-Folly.a(EventBase.o)
      folly::EventBase::loopBody(int, bool) in libFlipper-Folly.a(EventBase.o)
      folly::EventBase::nothingHandledYet() const in libFlipper-Folly.a(EventBase.o)
      folly::EventBase::bumpHandlingTime() in libFlipper-Folly.a(EventBase.o)
      folly::EventBase::terminateLoopSoon() in libFlipper-Folly.a(EventBase.o)
      folly::EventBase::SmoothLoopTime::SmoothLoopTime(std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000000l> >) in libFlipper-Folly.a(EventBase.o)
      ...
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

If I find something useful I come back here. Tell me if you want me to try something different.

@Darmolar
Copy link

Darmolar commented Sep 4, 2022

Thank you
this worked perfectly

@ricardobeat
Copy link

Flipper will not work. Disabling it only means you can't use Flipper. Everything else is normal. If you don't explicitly use Flipper, you won't notice. Setting it to FlipperConfiguration.disabled does the trick

Still working on Flipper just so it can work, but having Hermes working is great progress

Having Hermes without Flipper means it is impossible to debug network requests, which is a no-go for any production app. How is everyone working around this?

@mikehardy
Copy link
Collaborator

I believe the performance module of react-native-firebase may actually be of service here, otherwise you could perhaps use network analyzers? Sadly, I/we are not in control of the Flipper team's engineering resources and their prioritization of this issue but I encourage you to go vote on the linked issue.

@ricardobeat
Copy link

ricardobeat commented Jan 10, 2023

I was more interested in knowing what others are doing in practice, since react-native-firebase is the default for handling notifications, and right now using it means either kicking out Flipper, or disabling Hermes. So how can you get the performance benefits of Hermes and use FCM? Maybe nobody is actually running both in production yet. Unfortunately having the Firebase console as yet another required dev tool is a no-go.

@hexadecy
Copy link

@ricardobeat we're still on the 14.x waiting.

@robm-present-pal
Copy link

@hexadecy your comment was the fix we went with, as ours is a production app in which we were adding only analytics it was not feasible to drop flipper disrupting development.

Anybody interested in analytics without sacrificing flipper, follow the usual instructions but use
yarn add @react-native-firebase/app@^14.0.0 @react-native-firebase/analytics@^14.0.0
npx pod-install

@Shane-Goodwin
Copy link

This is what is currently working for me to use react-native-firebase:17.4.3 and react-native:0.71.7 with Hermes and Flipper enabled. Replace:

use_frameworks! :linkage => :static

with:

pod 'FirebaseCore', :modular_headers => true
pod 'FirebaseCoreExtension', :modular_headers => true
pod 'FirebaseInstallations', :modular_headers => true
pod 'GoogleDataTransport', :modular_headers => true
pod 'GoogleUtilities', :modular_headers => true
pod 'nanopb', :modular_headers => true

Keep this line below the changes:

$RNFirebaseAsStaticFramework = true

Hopefully Flipper becomes compatible with use_frameworks in the future , but this works in the meantime.

@ethanneff
Copy link

Thanks for the workaround in #6425 (comment)! This worked for me as well.

Firebase + Hermes + Flipper.

The only downside is that this increased my IPA file size by 0.9mb. From 26.3mb to 27.2mb.

@umangloria
Copy link

umangloria commented Jan 19, 2024

This is what is currently working for me to use react-native-firebase:17.4.3 and react-native:0.71.7 with Hermes and Flipper enabled. Replace:

use_frameworks! :linkage => :static

with:

pod 'FirebaseCore', :modular_headers => true
pod 'FirebaseCoreExtension', :modular_headers => true
pod 'FirebaseInstallations', :modular_headers => true
pod 'GoogleDataTransport', :modular_headers => true
pod 'GoogleUtilities', :modular_headers => true
pod 'nanopb', :modular_headers => true

Keep this line below the changes:

$RNFirebaseAsStaticFramework = true

Hopefully Flipper becomes compatible with use_frameworks in the future , but this works in the meantime.

Any idea on how to do this on expo managed project where iOS folder is not tracked on GitHub as it is generated automatically by Expo ?
--> NVM, I just looked above for the custom plugin for expo provided in one of the above reply. and it works fine with expo v49. Thanks

@atultiwaree
Copy link

Any suggestions on how do I use above solution with RN v 0.72.5, downgrading it to 0.71.7 is painfull

@mikehardy
Copy link
Collaborator

I'm not aware of a need to downgrade react-native. https://github.com/mikehardy/rnfbdemo/blob/main/make-demo.sh worked with react-native 0.71.x and it worked with 0.72.x

It uses the strictly required use_frameworks! :linkage => :static and has worked for every react-native version for years.

No support is offered or should be expected for any workarounds involving modular_headers for firebase dependencies

@Shane-Goodwin
Copy link

Any suggestions on how do I use above solution with RN v 0.72.5, downgrading it to 0.71.7 is painfull

My solution was still working for me with react-native-firebase:18.5.0 and react-native:0.72.6. Looking back in my commit history, I don't see any changes I had to make to support those versions. I can't speak to any versions after those.

My reason for finding an alternate solution was that at one time react-native-reanimated broke Chrome debugging in Android. Between that and having to disable Flipper, I was unable to effectively debug Android issues. And I know several other React Native libraries out there also have issues when using use_frameworks!. Trying to get several React Native packages to play together nicely has always been a challenge.

That said, mikehardy does great work in the React Native community. For future maintainability, your best bet is going to be sticking with his instructions to use use_frameworks! :linkage => :static

@atultiwaree
Copy link

atultiwaree commented Feb 19, 2024

@Shane-Goodwin @mikehardy

image

I'm getting above error in xcode

below is my podFile conent

image

for the time being without Shane's solution I'm using NO_FLIPPER=1 npx pod install but getting native module for flipper unavailable

Please suggest me what I do to use flipper

@Shane-Goodwin
Copy link

Go back and take a look at the documentation for Altering CocoaPods to use frameworks. It says to add use_frameworks! :linkage => :static inside your targets.

Using a vanilla react-native@0.72.6 install and react-native firebase, your podfile would look like this:

# 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 'fahdu' do
  config = use_native_modules!
  
  use_frameworks! :linkage => :static
  $RNFirebaseAsStaticFramework = true

  use_react_native!(
    :path => config[:reactNativePath],
    # 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 'fahduTests' 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

Download

Note: The latest versions of react-native now support use_frameworks via an environmental variable outside the targets, so I'm not sure that it's required to have it inside your targets, but I would nonetheless follow that documentation to a T until you get it working.

You might need to reset and reinstall your pods:
cd ios && rm -rf Pods && pod install && cd ../

Get that working first. Then if you want to try to enable Flipper, then remove use_frameworks! :linkage => :static and instead use this in its place:

pod 'FirebaseCore', :modular_headers => true
pod 'FirebaseCoreExtension', :modular_headers => true
pod 'FirebaseInstallations', :modular_headers => true
pod 'GoogleDataTransport', :modular_headers => true
pod 'GoogleUtilities', :modular_headers => true
pod 'nanopb', :modular_headers => true

I can't offer any support beyond that so if it doesn't work, then just stick with the original documentation.

@mikehardy
Copy link
Collaborator

Don't enable Flipper. Flipper has no future in the react-native community - you can read discussions upstream but if I understand correctly it is deprecated.

Best to use something different like good old console.log debugging or apparently reactotron

@atultiwaree
Copy link

@mikehardy @Shane-Goodwin Thanks a lot for support finally I've decided not to go with flipper mike is right in future I'll have to upgrade my project and flipper will again cause issue even after doing workarounds, so better is to go without flipper

@Lakston
Copy link

Lakston commented Feb 20, 2024

For now, if you are not using Hermes, you can use React Native Debugger until something comes out to replace it or they add Hermes support, or reactotron as suggested (never tried it)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help: needs-triage Issue needs additional investigation/triaging. type: bug New bug report
Projects
None yet
Development

No branches or pull requests