React-native-firebase: [iOS] Build target RNFBApp failed when use use_frameworks!

Created on 19 Dec 2019  路  14Comments  路  Source: invertase/react-native-firebase


Issue

Hi, I have issue when build target RNFBApp on iOS

Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_GULAppEnvironmentUtil", referenced from:
objc-class-ref in FirebaseCore(FIRBundleUtil.o)
"_GULResetLogger", referenced from:
_FIRResetLogger in FirebaseCore(FIRLogger.o)
"_GULLoggerRegisterVersion", referenced from:
___FIRLoggerInitializeASL_block_invoke in FirebaseCore(FIRLogger.o)
"_GULLoggerInitializeASL", referenced from:
___FIRLoggerInitializeASL_block_invoke in FirebaseCore(FIRLogger.o)
"_GULLogBasic", referenced from:
_FIRLogBasic in FirebaseCore(FIRLogger.o)
"_GULLoggerEnableSTDERR", referenced from:
___FIRLoggerInitializeASL_block_invoke in FirebaseCore(FIRLogger.o)
"_GULIsLoggableLevel", referenced from:
_FIRIsLoggableLevel in FirebaseCore(FIRLogger.o)
"_GULSetLoggerLevel", referenced from:
_FIRSetLoggerLevel in FirebaseCore(FIRLogger.o)
"_GULLoggerForceDebug", referenced from:
___FIRLoggerInitializeASL_block_invoke in FirebaseCore(FIRLogger.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

But if I remove use_frameworks! in Podfile then build successful.


Project Files






Javascript

Click To Expand

#### `package.json`:

    "react": "16.9.0",
    "react-native": "0.61.5",
    "@react-native-firebase/analytics": "^6.2.0",
    "@react-native-firebase/app": "^6.2.0",
    "@react-native-firebase/messaging": "^6.2.0",
    "@react-native-firebase/remote-config": "^6.2.0",
#### `firebase.json` for react-native-firebase v6:
# N/A
### iOS
Click To Expand

#### `ios/Podfile`: - [ ] I'm not using Pods - [x] I'm using Pods and my Podfile looks like:

platform :ios, '10.0'
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
...
use_frameworks!
#### `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`




Think react-native-firebase is great? Please consider supporting all of the project maintainers and contributors by donating via our Open Collective where all contributors can submit expenses. [Learn More]

Stale

Most helpful comment

v6.4.0 has been released which now has a flag to toggle using RNFirebase as a static framework: https://rnfirebase.io/#allow-ios-static-frameworks

All 14 comments

I fixed it with adding this at the end of Podfile

post_install do |installer|
  installer.pods_project.targets.each do |target|
    if ['RNFBApp', 'RNFBMessaging'].include?(target.name)
      target.add_system_framework(installer.pods_project.targets.find{|target| target.name == 'GoogleUtilities'})
      end
    if ['RNFBCrashlytics'].include?(target.name)
      target.add_system_framework(installer.pods_project.targets.find{|target| target.name == 'Fabric'})
      target.add_system_framework(installer.pods_project.targets.find{|target| target.name == 'Crashlytics'})
      end
  end
end

but I still face some issues regarding initialization of Firebase

I managed most problems by adding system_frameworks:

` post_install do |installer_representation|

  installer_representation.pods_project.targets.each do |target|
    if ['RNFBApp', 'RNFBMessaging', 'RNFBCrashlytics', 'RNFBDatabase'].include?(target.name)
      target.add_system_framework(installer_representation.pods_project.targets.find{|target| target.name == 'GoogleUtilities'})
    elsif target.name.eql?('RNFBAnalytics')
      target.add_system_framework(installer_representation.pods_project.targets.find{|target| target.name == 'FirebaseAnalytics'})
      target.add_system_framework(installer_representation.pods_project.targets.find{|target| target.name == 'GoogleAppMeasurement'})
      target.add_system_framework(installer_representation.pods_project.targets.find{|target| target.name == 'nanopb'})
      target.add_system_framework(installer_representation.pods_project.targets.find{|target| target.name == 'GoogleUtilities'})
    end
    if ['RNFBCrashlytics'].include?(target.name)
      target.add_system_framework(installer_representation.pods_project.targets.find{|target| target.name == 'Fabric'})
      target.add_system_framework(installer_representation.pods_project.targets.find{|target| target.name == 'Crashlytics'})
      end
    if ['RNFBDatabase'].include?(target.name)
      target.add_system_framework(installer_representation.pods_project.targets.find{|target| target.name == 'GoogleUtilities'})
      target.add_system_framework(installer_representation.pods_project.targets.find{|target| target.name == 'FirebaseDatabase'})
      target.add_system_framework(installer_representation.pods_project.targets.find{|target| target.name == 'leveldb'})
      end
  end

end`

but it doesn't work for FirebaseDatabase:

Undefined symbols for architecture x86_64: "leveldb::WriteBatch::WriteBatch()", referenced from: -[APLevelDBWriteBatch .cxx_construct] in FirebaseDatabase(APLevelDB.o) "leveldb::WriteBatch::Clear()", referenced from: -[APLevelDBWriteBatch clear] in FirebaseDatabase(APLevelDB.o) "leveldb::Status::ToString() const", referenced from: -[APLevelDB initWithPath:error:] in FirebaseDatabase(APLevelDB.o) "leveldb::DB::Open(leveldb::Options const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, leveldb::DB**)", referenced from: -[APLevelDB initWithPath:error:] in FirebaseDatabase(APLevelDB.o) "leveldb::WriteBatch::Delete(leveldb::Slice const&)", referenced from: -[APLevelDBWriteBatch removeKey:] in FirebaseDatabase(APLevelDB.o) "leveldb::WriteBatch::~WriteBatch()", referenced from: -[APLevelDBWriteBatch .cxx_destruct] in FirebaseDatabase(APLevelDB.o) "leveldb::WriteBatch::Put(leveldb::Slice const&, leveldb::Slice const&)", referenced from: -[APLevelDBWriteBatch setData:forKey:] in FirebaseDatabase(APLevelDB.o) -[APLevelDBWriteBatch setString:forKey:] in FirebaseDatabase(APLevelDB.o) "leveldb::Options::Options()", referenced from: +[APLevelDB defaultCreateOptions] in FirebaseDatabase(APLevelDB.o) ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

I fixed it with adding this at the end of Podfile

post_install do |installer|
  installer.pods_project.targets.each do |target|
    if ['RNFBApp', 'RNFBMessaging'].include?(target.name)
      target.add_system_framework(installer.pods_project.targets.find{|target| target.name == 'GoogleUtilities'})
      end
    if ['RNFBCrashlytics'].include?(target.name)
      target.add_system_framework(installer.pods_project.targets.find{|target| target.name == 'Fabric'})
      target.add_system_framework(installer.pods_project.targets.find{|target| target.name == 'Crashlytics'})
      end
  end
end

but I still face some issues regarding initialization of Firebase

Here is the same with this podfile config:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    if ['RNFBApp', 'RNFBMessaging' ].include?(target.name)
      target.add_system_framework(installer.pods_project.targets.find{|target| target.name == 'GoogleUtilities'})
    elsif ['RNFBCrashlytics'].include?(target.name)
      target.add_system_framework(installer.pods_project.targets.find{|target| target.name == 'Fabric'})
      target.add_system_framework(installer.pods_project.targets.find{|target| target.name == 'Crashlytics'})
    elsif target.name.eql?('RNFBAnalytics')
      target.add_system_framework(installer.pods_project.targets.find{|target| target.name == 'FirebaseAnalytics'})
      target.add_system_framework(installer.pods_project.targets.find{|target| target.name == 'GoogleAppMeasurement'})
      target.add_system_framework(installer.pods_project.targets.find{|target| target.name == 'nanopb'})
      target.add_system_framework(installer.pods_project.targets.find{|target| target.name == 'GoogleUtilities'})
    elsif target.name.eql?('RNFBPerf')
      target.add_system_framework(installer.pods_project.targets.find{|target| target.name == 'FirebasePerformance'})
      target.add_system_framework(installer.pods_project.targets.find{|target| target.name == 'GTMSessionFetcher'})
      target.add_system_framework(installer.pods_project.targets.find{|target| target.name == 'GoogleToolboxForMac'})
    end
  end
end

IOS Native initialization in appDelegate seems to failed cause JS thread throw exception....

Simulator Screen Shot - iPhone X - 2020-01-08 at 10 37 54

I've got this in Xcode logs:

objc[1549]: Class APMConditionalUserPropertyController is implemented in both /private/var/containers/Bundle/Application/1B28CB32-FAEC-4DEC-BA1D-6EB0656DE959/myApp.app/Frameworks/RNFBAnalytics.framework/RNFBAnalytics (0x106960ef0) and /var/containers/Bundle/Application/1B28CB32-FAEC-4DEC-BA1D-6EB0656DE959/myApp.app/myApp (0x100936420). One of the two will be used. Which one is undefined.
2020-01-08 13:24:50.829175+0100 myApp[1549:367410] -[APMConditionalUserPropertyController processEventOnWorkerQueue:]: unrecognized selector sent to instance 0x28111dd50
2020-01-08 13:24:50.834699+0100 myApp[1549:367410] 6.13.0 - [Firebase/Analytics][I-ACS030000] Exception on worker queue. Block ID=APMMeasurement:2366. Exception: -[APMMeasurement handleEventOnWorkerQueue:]: -[APMConditionalUserPropertyController processEventOnWorkerQueue:]: unrecognized selector sent to instance 0x28111dd50
2020-01-08 13:24:51.818065+0100 myApp[1549:367385] -[APMConditionalUserPropertyController processEventOnWorkerQueue:]: unrecognized selector sent to instance 0x28111dd50
2020-01-08 13:24:51.819187+0100 myApp[1549:367385] 6.13.0 - [Firebase/Analytics][I-ACS030000] Exception on worker queue. Block ID=APMMeasurement:2366. Exception: -[APMMeasurement handleEventOnWorkerQueue:]: -[APMConditionalUserPropertyController processEventOnWorkerQueue:]: unrecognized selector sent to instance 0x28111dd50

NB: Android works fine

Thanks a lot, @Aurelienlajoinie, it works for me!

Do you have any solution for FirebaseDatabase ?

I'm experiencing this error as well. I need to use Mapbox iOS SDK which requires use_frameworks!, so a work around or fix for this issue would help. To manually initialize the FirebaseDatabase do we just call initialiseApp()?

Getting the same issue with Firebase initialisation after adding the post_install hook.

I manage to build my app without using the podfile postinstall script and i got no error at launch on iOS.
I turn static_framework from podspec to true for each used package (using patch package)

Example for Analytics:

diff --git a/node_modules/@react-native-firebase/analytics/RNFBAnalytics.podspec b/node_modules/@react-native-firebase/analytics/RNFBAnalytics.podspec
index 0e09692..d865ab5 100644
--- a/node_modules/@react-native-firebase/analytics/RNFBAnalytics.podspec
+++ b/node_modules/@react-native-firebase/analytics/RNFBAnalytics.podspec
@@ -25,5 +25,5 @@ Pod::Spec.new do |s|
   s.dependency          'React'
   s.dependency          'Firebase/Core', firebase_sdk_version
   s.dependency          'RNFBApp'
-  s.static_framework    = false
+  s.static_framework    = true
 end

What does the static_framework attribute ? Is it a real solution to do that ?

Thanks in advance for your help :)

Hi still having a similar issue when trying to install react-native-firebase/analytics 6.3.1 on RN 0.61.5. I have added that post_install script but have had no luck. Anyone else facing this issue??

Hi still having a similar issue when trying to install react-native-firebase/analytics 6.3.1 on RN 0.61.5. I have added that post_install script but have had no luck. Anyone else facing this issue??

I had a similar issue because I use abstract_target for all of my schemas. My solution was to move use_native_modules to regular targets, so it looks like this:

abstract_target 'HomeisShared' do    
  // my shared dependencies go here

  target 'HomeisMobile' do
    use_native_modules!
  end

  target 'HomeisMobileStage' do
    use_native_modules!
  end

  target 'HomeisMobileDev' do
    use_native_modules!
  end
end  

Hope this helps

If you use RNFBAuth, add it like RNFBAnalytics:

elsif ['RNFBAnalytics', 'RNFBAuth'].include?(target.name)
       target.add_system_framework(installer.pods_project.targets.find{|target| target.name == 'FirebaseAnalytics'})
       target.add_system_framework(installer.pods_project.targets.find{|target| target.name == 'GoogleAppMeasurement'})
       target.add_system_framework(installer.pods_project.targets.find{|target| target.name == 'nanopb'})
       target.add_system_framework(installer.pods_project.targets.find{|target| target.name == 'GoogleUtilities'})

You might not need to add above 4 frameworks for RNFBAuth, but I don't have time to test :D

If you use another RNFB and dont know framework to add:*
See the error and grep the package name (eg: GULAppEnvironmentUtil)
==> Then google with that package name, you might find the needed framework:
image

I found that this workaround can fix the issue too:
https://github.com/invertase/react-native-firebase/issues/3253#issuecomment-595022962

If it change to static_frameworks. You don't need to fix this anymore:
https://github.com/invertase/react-native-firebase/issues/3024#issuecomment-568287357

Hello 馃憢, to help manage issues we automatically close stale issues.
This issue has been automatically marked as stale because it has not had activity for quite some time. Has this issue been fixed, or does it still require the community's attention?

This issue will be closed in 15 days if no further activity occurs.
Thank you for your contributions.

v6.4.0 has been released which now has a flag to toggle using RNFirebase as a static framework: https://rnfirebase.io/#allow-ios-static-frameworks

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hapo-hoangnh picture hapo-hoangnh  路  52Comments

neverlan picture neverlan  路  47Comments

gilbert picture gilbert  路  65Comments

AdamGold picture AdamGold  路  194Comments

elledienne picture elledienne  路  55Comments