RNFirebase doesn’t compile with use_frameworks!

I really love using your library but unfortunately iOS compilation breaks when I add use_frameworks! to the Podfile.

I was able to combine RNFirebase and FirebaseUI-iOS. Phone Authentication in FirebaseUI triggered firebase.auth().onAuthStateChanged with correct user Id, which felt great.

However, in order to add “Login with Facebook” I have to enable use_frameworks!. Otherwise FirebaseUI won’t build – it’s a known issue with FirebaseUI/FBSDKLoginKit combo.
Enabling use_frameworks breaks RNFirebase.

Quickest way to reproduce the issue is to run this script, it will create and build a RN project:

cd $(mktemp -d)
pwd > YOU_ARE_HERE.txt
echo FooBar in created on $(date). Working dir >> ~/my_foobars.txt
echo $(pwd) >> ~/my_foobars.txt

open .
react-native init FooBar
cd FooBar
react-native install react-native-firebase
cat >ios/Podfile <<EOF
platform :ios, '9.0'

# comment out the next line to make RNFirebase great again.
use_frameworks!

react_native_path = '../node_modules/react-native'
target 'FooBar' do
  pod 'Yoga', :path => react_native_path + '/ReactCommon/yoga'
  pod 'React', :path => react_native_path, :subspecs => [
    'BatchedBridge',
    'Core',
  ]

  pod 'FirebaseAnalytics'
  pod 'Firebase/Core'
  pod 'Firebase/AdMob'
  pod 'Firebase/Auth'
  pod 'Firebase/Analytics'
  pod 'Firebase/Crash'
  pod 'Firebase/Database'
  pod 'Firebase/DynamicLinks'
  pod 'Firebase/Messaging'
  pod 'Firebase/RemoteConfig'
  pod 'Firebase/Storage'
  pod 'FirebaseUI/Auth'
  pod 'FirebaseUI/Phone'

  pod 'RNFirebase', :path => '../node_modules/react-native-firebase'
end
EOF

cd ios && pod install && cd .. && react-native run-ios

Error:

CompileC /var/folders/1_/zbm5sxxj7rbgbvxqv5xdy7pr0000gp/T/tmp.JygzFQ2B/FooBar/ios/build/Build/Intermediates/Pods.build/Debug-iphonesimulator/RNFirebase.build/Objects-normal/x86_64/RNFirebase.o /var/folders/1_/zbm5sxxj7rbgbvxqv5xdy7pr0000gp/T/tmp.JygzFQ2B/FooBar/node_modules/react-native-firebase/ios/RNFirebase/RNFirebase.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler
    cd /var/folders/1_/zbm5sxxj7rbgbvxqv5xdy7pr0000gp/T/tmp.JygzFQ2B/FooBar/ios/Pods
    export LANG=en_US.US-ASCII
    export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/Users/paul/google-cloud-sdk/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Users/paul/Library/Android/sdk/tools:/Users/paul/.yarn/bin"
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x objective-c -arch x86_64 -fmessage-length=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -std=gnu99 -fobjc-arc -fmodules -gmodules -fmodules-cache-path=/var/folders/1_/zbm5sxxj7rbgbvxqv5xdy7pr0000gp/T/tmp.JygzFQ2B/FooBar/ios/build/ModuleCache -fmodules-prune-interval=86400 -fmodules-prune-after=345600 -fbuild-session-file=/var/folders/1_/zbm5sxxj7rbgbvxqv5xdy7pr0000gp/T/tmp.JygzFQ2B/FooBar/ios/build/ModuleCache/Session.modulevalidation -fmodules-validate-once-per-build-session -Wnon-modular-include-in-framework-module -Werror=non-modular-include-in-framework-module -Xclang -fmodule-implementation-of -Xclang RNFirebase -Wno-trigraphs -fpascal-strings -O0 -fno-common -Wno-missing-field-initializers -Wno-missing-prototypes -Wdocumentation -Wunreachable-code -Wno-implicit-atomic-properties -Wno-arc-repeated-use-of-weak -Wduplicate-method-match -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wuninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wshorten-64-to-32 -Wpointer-sign -Wno-newline-eof -Wno-selector -Wno-strict-selector-match -Wundeclared-selector -Wno-deprecated-implementations -DPOD_CONFIGURATION_DEBUG=1 -DDEBUG=1 -DCOCOAPODS=1 -DOBJC_OLD_DISPATCH_PROTOTYPES=0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.3.sdk -fasm-blocks -fstrict-aliasing -Wprotocol -Wdeprecated-declarations -mios-simulator-version-min=8.0 -g -Wno-sign-conversion -Winfinite-recursion -fobjc-abi-version=2 -fobjc-legacy-dispatch -iquote /var/folders/1_/zbm5sxxj7rbgbvxqv5xdy7pr0000gp/T/tmp.JygzFQ2B/FooBar/ios/build/Build/Intermediates/Pods.build/Debug-iphonesimulator/RNFirebase.build/RNFirebase-generated-files.hmap -I/var/folders/1_/zbm5sxxj7rbgbvxqv5xdy7pr0000gp/T/tmp.JygzFQ2B/FooBar/ios/build/Build/Intermediates/Pods.build/Debug-iphonesimulator/RNFirebase.build/RNFirebase-own-target-headers.hmap -I/var/folders/1_/zbm5sxxj7rbgbvxqv5xdy7pr0000gp/T/tmp.JygzFQ2B/FooBar/ios/build/Build/Intermediates/Pods.build/Debug-iphonesimulator/RNFirebase.build/RNFirebase-all-non-framework-target-headers.hmap -ivfsoverlay /var/folders/1_/zbm5sxxj7rbgbvxqv5xdy7pr0000gp/T/tmp.JygzFQ2B/FooBar/ios/build/Build/Intermediates/Pods.build/all-product-headers.yaml -iquote /var/folders/1_/zbm5sxxj7rbgbvxqv5xdy7pr0000gp/T/tmp.JygzFQ2B/FooBar/ios/build/Build/Intermediates/Pods.build/Debug-iphonesimulator/RNFirebase.build/RNFirebase-project-headers.hmap -I/var/folders/1_/zbm5sxxj7rbgbvxqv5xdy7pr0000gp/T/tmp.JygzFQ2B/FooBar/ios/build/Build/Products/Debug-iphonesimulator/RNFirebase/include -I/var/folders/1_/zbm5sxxj7rbgbvxqv5xdy7pr0000gp/T/tmp.JygzFQ2B/FooBar/ios/Pods/Headers/Private -I/var/folders/1_/zbm5sxxj7rbgbvxqv5xdy7pr0000gp/T/tmp.JygzFQ2B/FooBar/ios/Pods/Headers/Public -I/var/folders/1_/zbm5sxxj7rbgbvxqv5xdy7pr0000gp/T/tmp.JygzFQ2B/FooBar/ios/Pods/Headers/Public/Firebase -I/var/folders/1_/zbm5sxxj7rbgbvxqv5xdy7pr0000gp/T/tmp.JygzFQ2B/FooBar/ios/Pods/Headers/Public/FirebaseAnalytics -I/var/folders/1_/zbm5sxxj7rbgbvxqv5xdy7pr0000gp/T/tmp.JygzFQ2B/FooBar/ios/Pods/Headers/Public/FirebaseAuth -I/var/folders/1_/zbm5sxxj7rbgbvxqv5xdy7pr0000gp/T/tmp.JygzFQ2B/FooBar/ios/Pods/Headers/Public/FirebaseCore -I/var/folders/1_/zbm5sxxj7rbgbvxqv5xdy7pr0000gp/T/tmp.JygzFQ2B/FooBar/ios/Pods/Headers/Public/FirebaseCrash -I/var/folders/1_/zbm5sxxj7rbgbvxqv5xdy7pr0000gp/T/tmp.JygzFQ2B/FooBar/ios/Pods/Headers/Public/FirebaseDatabase -I/var/folders/1_/zbm5sxxj7rbgbvxqv5xdy7pr0000gp/T/tmp.JygzFQ2B/FooBar/ios/Pods/Headers/Public/FirebaseDynamicLinks -I/var/folders/1_/zbm5sxxj7rbgbvxqv5xdy7pr0000gp/T/tmp.JygzFQ2B/FooBar/ios/Pods/Headers/Public/FirebaseInstanceID -I/var/folders/1_/zbm5sxxj7rbgbvxqv5xdy7pr0000gp/T/tmp.JygzFQ2B/FooBar/ios/Pods/Headers/Public/FirebaseMessaging -I/var/folders/1_/zbm5sxxj7rbgbvxqv5xdy7pr0000gp/T/tmp.JygzFQ2B/FooBar/ios/Pods/Headers/Public/FirebaseRemoteConfig -I/var/folders/1_/zbm5sxxj7rbgbvxqv5xdy7pr0000gp/T/tmp.JygzFQ2B/FooBar/ios/Pods/Headers/Public/FirebaseStorage -I/var/folders/1_/zbm5sxxj7rbgbvxqv5xdy7pr0000gp/T/tmp.JygzFQ2B/FooBar/ios/Pods/Headers/Public/FirebaseUI -I/var/folders/1_/zbm5sxxj7rbgbvxqv5xdy7pr0000gp/T/tmp.JygzFQ2B/FooBar/ios/Pods/Headers/Public/Google-Mobile-Ads-SDK -I/var/folders/1_/zbm5sxxj7rbgbvxqv5xdy7pr0000gp/T/tmp.JygzFQ2B/FooBar/ios/build/Build/Intermediates/Pods.build/Debug-iphonesimulator/RNFirebase.build/DerivedSources/x86_64 -I/var/folders/1_/zbm5sxxj7rbgbvxqv5xdy7pr0000gp/T/tmp.JygzFQ2B/FooBar/ios/build/Build/Intermediates/Pods.build/Debug-iphonesimulator/RNFirebase.build/DerivedSources -F/var/folders/1_/zbm5sxxj7rbgbvxqv5xdy7pr0000gp/T/tmp.JygzFQ2B/FooBar/ios/build/Build/Products/Debug-iphonesimulator/RNFirebase -include /var/folders/1_/zbm5sxxj7rbgbvxqv5xdy7pr0000gp/T/tmp.JygzFQ2B/FooBar/ios/Pods/Target\ Support\ Files/RNFirebase/RNFirebase-prefix.pch -MMD -MT dependencies -MF /var/folders/1_/zbm5sxxj7rbgbvxqv5xdy7pr0000gp/T/tmp.JygzFQ2B/FooBar/ios/build/Build/Intermediates/Pods.build/Debug-iphonesimulator/RNFirebase.build/Objects-normal/x86_64/RNFirebase.d --serialize-diagnostics /var/folders/1_/zbm5sxxj7rbgbvxqv5xdy7pr0000gp/T/tmp.JygzFQ2B/FooBar/ios/build/Build/Intermediates/Pods.build/Debug-iphonesimulator/RNFirebase.build/Objects-normal/x86_64/RNFirebase.dia -c /var/folders/1_/zbm5sxxj7rbgbvxqv5xdy7pr0000gp/T/tmp.JygzFQ2B/FooBar/node_modules/react-native-firebase/ios/RNFirebase/RNFirebase.m -o /var/folders/1_/zbm5sxxj7rbgbvxqv5xdy7pr0000gp/T/tmp.JygzFQ2B/FooBar/ios/build/Build/Intermediates/Pods.build/Debug-iphonesimulator/RNFirebase.build/Objects-normal/x86_64/RNFirebase.o
In file included from /var/folders/1_/zbm5sxxj7rbgbvxqv5xdy7pr0000gp/T/tmp.JygzFQ2B/FooBar/node_modules/react-native-firebase/ios/RNFirebase/RNFirebase.m:1:
/var/folders/1_/zbm5sxxj7rbgbvxqv5xdy7pr0000gp/T/tmp.JygzFQ2B/FooBar/node_modules/react-native-firebase/ios/RNFirebase/RNFirebase.h:4:9: fatal error: 'React/RCTEventEmitter.h' file not found
#import <React/RCTEventEmitter.h>
        ^
1 error generated.

...node_modules/react-native-firebase/ios/RNFirebase/RNFirebase.h:4:9: fatal error: 'React/RCTEventEmitter.h' file not found

Why fix it here

It would be really great to have compatibility between RNFirebase and FirebaseUI.
There’s an official Android version of FirebaseUI, and Facebook is a rather popular login method, so unblocking a road towards a proper RNFirebaseUI package would be valuable for the whole community.

Root cause is obviously the over-complicated and ugly XCode build system, but maybe there’s a not too hard fix on your side.
I will raise an issue with FirebaseUI-iOS as they seem to be open to supporting non-frameworks build but obviously no guarantees or ETAs there.

Environment

$ uname -a
Darwin Redacted.local 16.6.0 Darwin Kernel Version 16.6.0: Fri Apr 14 16:21:16 PDT 2017; root:xnu-3789.60.24~6/RELEASE_X86_64 x86_64
$ xcodebuild -version
Xcode 8.3.3
Build version 8E3004b
$ pod --version
1.3.0.beta.2

"dependencies": {
	"react": "16.0.0-alpha.12",
	"react-native": "0.46.2",
	"react-native-firebase": "^2.0.3"
},

Author: Fantashit

7 thoughts on “RNFirebase doesn’t compile with use_frameworks!

  1. I’ve just been investigating this further and whilst I’ve resolved the issue with RNFirebase not being able to see React imports, this only got me to a bigger issue:

    Unfortunately it seems that Firebase is fundamentally broken when using the !use_frameworks flags and it’s being imported by a third party library, i.e. RNFirebase. This is discussed in some detail here: CocoaPods/CocoaPods#5368 and acknowledged by somebody at Google here: firebase/firebase-ios-sdk#58 (comment)

    FirebaseUI have got around this issue by actually embedding the Firebase dependencies within their library directly. This approach doesn’t work for us, as it would mean every app using RNFirebase would have every Firebase library added to it whether they’re using the functionality or not. This adds unnecessary bloat and is something we’re not keen to do.

    I’ve reached out to a contact at Firebase directly to see what we might be able to do in order to resolve this satisfactorily, but until then, I’m afraid that I don’t have a way of working around this issue.

  2. @nagad814 I have just updated the release notes to make it clear that you should still use cocoapods for the Firebase SDK, but not for react-native-firebase itself

  3. For anyone looking for a workaround with 5.x & use_framework! this days, add this to your Podfile

    post_install do |installer|
      # react-native-firebase need some adjustements  with use_frameworks!
      rnfirebase = installer.pods_project.targets.find { |target| target.name == 'RNFirebase' }
      rnfirebase.build_configurations.each do |config|
        # react-native-firebase HEADER_SEARCH_PATHS are not good
        # This is to avoid the error
        # 'Firebase.h' file not found with <angled> include; use "quotes" instead
        config.build_settings['HEADER_SEARCH_PATHS'] = '$(inherited) ${PODS_ROOT}/Headers/Public/**'
        # injecting `s.static_framework = true`
        # (should be in RNFirebase.podspec but since it's not, the code below is doing the same behavior)
        config.build_settings['MACH_O_TYPE'] = 'staticlib'
      end
    end
    
    pre_install do |installer|
      # workaround for https://github.com/CocoaPods/CocoaPods/issues/3289
      # to avoid 
      # [!] The 'Pods-ADM' target has transitive dependencies that include statically linked binaries: (FirebaseCore, FirebaseInstanceID, FirebaseDynamicLinks, and FirebaseMessaging)
      Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}
    end

    🎉 It took me 2 days to understand what I was doing but I think I got it right 🙂

  4. For people interested in this issue, there is an opportunity to collaborate with react-native folks on how to make use_frameworks work better:

    https://github.com/facebook/react-native/releases/tag/v0.61.0-rc.0

        Better CocoaPods support with use_frameworks!
    
        Note: If you are using CocoaPods with use_frameworks!, you may be required to add s.static_framework = true to each podspec that depends on React Native. This is a temporary solution and we are working on a better way to integrate with the community packages before we ship a stable release.
    
  5. I used below script to automate #252 (comment)

    pre_install do |installer|
      installer.pod_targets.each do |pod|
        if pod.name.start_with?('RNFB')
          def pod.build_type;
            Pod::Target::BuildType.static_library
          end
        end
      end
    end

Comments are closed.

RNFirebase doesn’t compile with use_frameworks!

I really love using your library but unfortunately iOS compilation breaks when I add use_frameworks! to the Podfile.

I was able to combine RNFirebase and FirebaseUI-iOS. Phone Authentication in FirebaseUI triggered firebase.auth().onAuthStateChanged with correct user Id, which felt great.

However, in order to add “Login with Facebook” I have to enable use_frameworks!. Otherwise FirebaseUI won’t build – it’s a known issue with FirebaseUI/FBSDKLoginKit combo.
Enabling use_frameworks breaks RNFirebase.

Quickest way to reproduce the issue is to run this script, it will create and build a RN project:

cd $(mktemp -d)
pwd > YOU_ARE_HERE.txt
echo FooBar in created on $(date). Working dir >> ~/my_foobars.txt
echo $(pwd) >> ~/my_foobars.txt

open .
react-native init FooBar
cd FooBar
react-native install react-native-firebase
cat >ios/Podfile <<EOF
platform :ios, '9.0'

# comment out the next line to make RNFirebase great again.
use_frameworks!

react_native_path = '../node_modules/react-native'
target 'FooBar' do
  pod 'Yoga', :path => react_native_path + '/ReactCommon/yoga'
  pod 'React', :path => react_native_path, :subspecs => [
    'BatchedBridge',
    'Core',
  ]

  pod 'FirebaseAnalytics'
  pod 'Firebase/Core'
  pod 'Firebase/AdMob'
  pod 'Firebase/Auth'
  pod 'Firebase/Analytics'
  pod 'Firebase/Crash'
  pod 'Firebase/Database'
  pod 'Firebase/DynamicLinks'
  pod 'Firebase/Messaging'
  pod 'Firebase/RemoteConfig'
  pod 'Firebase/Storage'
  pod 'FirebaseUI/Auth'
  pod 'FirebaseUI/Phone'

  pod 'RNFirebase', :path => '../node_modules/react-native-firebase'
end
EOF

cd ios && pod install && cd .. && react-native run-ios

Error:

CompileC /var/folders/1_/zbm5sxxj7rbgbvxqv5xdy7pr0000gp/T/tmp.JygzFQ2B/FooBar/ios/build/Build/Intermediates/Pods.build/Debug-iphonesimulator/RNFirebase.build/Objects-normal/x86_64/RNFirebase.o /var/folders/1_/zbm5sxxj7rbgbvxqv5xdy7pr0000gp/T/tmp.JygzFQ2B/FooBar/node_modules/react-native-firebase/ios/RNFirebase/RNFirebase.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler
    cd /var/folders/1_/zbm5sxxj7rbgbvxqv5xdy7pr0000gp/T/tmp.JygzFQ2B/FooBar/ios/Pods
    export LANG=en_US.US-ASCII
    export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/Users/paul/google-cloud-sdk/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Users/paul/Library/Android/sdk/tools:/Users/paul/.yarn/bin"
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x objective-c -arch x86_64 -fmessage-length=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -std=gnu99 -fobjc-arc -fmodules -gmodules -fmodules-cache-path=/var/folders/1_/zbm5sxxj7rbgbvxqv5xdy7pr0000gp/T/tmp.JygzFQ2B/FooBar/ios/build/ModuleCache -fmodules-prune-interval=86400 -fmodules-prune-after=345600 -fbuild-session-file=/var/folders/1_/zbm5sxxj7rbgbvxqv5xdy7pr0000gp/T/tmp.JygzFQ2B/FooBar/ios/build/ModuleCache/Session.modulevalidation -fmodules-validate-once-per-build-session -Wnon-modular-include-in-framework-module -Werror=non-modular-include-in-framework-module -Xclang -fmodule-implementation-of -Xclang RNFirebase -Wno-trigraphs -fpascal-strings -O0 -fno-common -Wno-missing-field-initializers -Wno-missing-prototypes -Wdocumentation -Wunreachable-code -Wno-implicit-atomic-properties -Wno-arc-repeated-use-of-weak -Wduplicate-method-match -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wuninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wshorten-64-to-32 -Wpointer-sign -Wno-newline-eof -Wno-selector -Wno-strict-selector-match -Wundeclared-selector -Wno-deprecated-implementations -DPOD_CONFIGURATION_DEBUG=1 -DDEBUG=1 -DCOCOAPODS=1 -DOBJC_OLD_DISPATCH_PROTOTYPES=0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.3.sdk -fasm-blocks -fstrict-aliasing -Wprotocol -Wdeprecated-declarations -mios-simulator-version-min=8.0 -g -Wno-sign-conversion -Winfinite-recursion -fobjc-abi-version=2 -fobjc-legacy-dispatch -iquote /var/folders/1_/zbm5sxxj7rbgbvxqv5xdy7pr0000gp/T/tmp.JygzFQ2B/FooBar/ios/build/Build/Intermediates/Pods.build/Debug-iphonesimulator/RNFirebase.build/RNFirebase-generated-files.hmap -I/var/folders/1_/zbm5sxxj7rbgbvxqv5xdy7pr0000gp/T/tmp.JygzFQ2B/FooBar/ios/build/Build/Intermediates/Pods.build/Debug-iphonesimulator/RNFirebase.build/RNFirebase-own-target-headers.hmap -I/var/folders/1_/zbm5sxxj7rbgbvxqv5xdy7pr0000gp/T/tmp.JygzFQ2B/FooBar/ios/build/Build/Intermediates/Pods.build/Debug-iphonesimulator/RNFirebase.build/RNFirebase-all-non-framework-target-headers.hmap -ivfsoverlay /var/folders/1_/zbm5sxxj7rbgbvxqv5xdy7pr0000gp/T/tmp.JygzFQ2B/FooBar/ios/build/Build/Intermediates/Pods.build/all-product-headers.yaml -iquote /var/folders/1_/zbm5sxxj7rbgbvxqv5xdy7pr0000gp/T/tmp.JygzFQ2B/FooBar/ios/build/Build/Intermediates/Pods.build/Debug-iphonesimulator/RNFirebase.build/RNFirebase-project-headers.hmap -I/var/folders/1_/zbm5sxxj7rbgbvxqv5xdy7pr0000gp/T/tmp.JygzFQ2B/FooBar/ios/build/Build/Products/Debug-iphonesimulator/RNFirebase/include -I/var/folders/1_/zbm5sxxj7rbgbvxqv5xdy7pr0000gp/T/tmp.JygzFQ2B/FooBar/ios/Pods/Headers/Private -I/var/folders/1_/zbm5sxxj7rbgbvxqv5xdy7pr0000gp/T/tmp.JygzFQ2B/FooBar/ios/Pods/Headers/Public -I/var/folders/1_/zbm5sxxj7rbgbvxqv5xdy7pr0000gp/T/tmp.JygzFQ2B/FooBar/ios/Pods/Headers/Public/Firebase -I/var/folders/1_/zbm5sxxj7rbgbvxqv5xdy7pr0000gp/T/tmp.JygzFQ2B/FooBar/ios/Pods/Headers/Public/FirebaseAnalytics -I/var/folders/1_/zbm5sxxj7rbgbvxqv5xdy7pr0000gp/T/tmp.JygzFQ2B/FooBar/ios/Pods/Headers/Public/FirebaseAuth -I/var/folders/1_/zbm5sxxj7rbgbvxqv5xdy7pr0000gp/T/tmp.JygzFQ2B/FooBar/ios/Pods/Headers/Public/FirebaseCore -I/var/folders/1_/zbm5sxxj7rbgbvxqv5xdy7pr0000gp/T/tmp.JygzFQ2B/FooBar/ios/Pods/Headers/Public/FirebaseCrash -I/var/folders/1_/zbm5sxxj7rbgbvxqv5xdy7pr0000gp/T/tmp.JygzFQ2B/FooBar/ios/Pods/Headers/Public/FirebaseDatabase -I/var/folders/1_/zbm5sxxj7rbgbvxqv5xdy7pr0000gp/T/tmp.JygzFQ2B/FooBar/ios/Pods/Headers/Public/FirebaseDynamicLinks -I/var/folders/1_/zbm5sxxj7rbgbvxqv5xdy7pr0000gp/T/tmp.JygzFQ2B/FooBar/ios/Pods/Headers/Public/FirebaseInstanceID -I/var/folders/1_/zbm5sxxj7rbgbvxqv5xdy7pr0000gp/T/tmp.JygzFQ2B/FooBar/ios/Pods/Headers/Public/FirebaseMessaging -I/var/folders/1_/zbm5sxxj7rbgbvxqv5xdy7pr0000gp/T/tmp.JygzFQ2B/FooBar/ios/Pods/Headers/Public/FirebaseRemoteConfig -I/var/folders/1_/zbm5sxxj7rbgbvxqv5xdy7pr0000gp/T/tmp.JygzFQ2B/FooBar/ios/Pods/Headers/Public/FirebaseStorage -I/var/folders/1_/zbm5sxxj7rbgbvxqv5xdy7pr0000gp/T/tmp.JygzFQ2B/FooBar/ios/Pods/Headers/Public/FirebaseUI -I/var/folders/1_/zbm5sxxj7rbgbvxqv5xdy7pr0000gp/T/tmp.JygzFQ2B/FooBar/ios/Pods/Headers/Public/Google-Mobile-Ads-SDK -I/var/folders/1_/zbm5sxxj7rbgbvxqv5xdy7pr0000gp/T/tmp.JygzFQ2B/FooBar/ios/build/Build/Intermediates/Pods.build/Debug-iphonesimulator/RNFirebase.build/DerivedSources/x86_64 -I/var/folders/1_/zbm5sxxj7rbgbvxqv5xdy7pr0000gp/T/tmp.JygzFQ2B/FooBar/ios/build/Build/Intermediates/Pods.build/Debug-iphonesimulator/RNFirebase.build/DerivedSources -F/var/folders/1_/zbm5sxxj7rbgbvxqv5xdy7pr0000gp/T/tmp.JygzFQ2B/FooBar/ios/build/Build/Products/Debug-iphonesimulator/RNFirebase -include /var/folders/1_/zbm5sxxj7rbgbvxqv5xdy7pr0000gp/T/tmp.JygzFQ2B/FooBar/ios/Pods/Target\ Support\ Files/RNFirebase/RNFirebase-prefix.pch -MMD -MT dependencies -MF /var/folders/1_/zbm5sxxj7rbgbvxqv5xdy7pr0000gp/T/tmp.JygzFQ2B/FooBar/ios/build/Build/Intermediates/Pods.build/Debug-iphonesimulator/RNFirebase.build/Objects-normal/x86_64/RNFirebase.d --serialize-diagnostics /var/folders/1_/zbm5sxxj7rbgbvxqv5xdy7pr0000gp/T/tmp.JygzFQ2B/FooBar/ios/build/Build/Intermediates/Pods.build/Debug-iphonesimulator/RNFirebase.build/Objects-normal/x86_64/RNFirebase.dia -c /var/folders/1_/zbm5sxxj7rbgbvxqv5xdy7pr0000gp/T/tmp.JygzFQ2B/FooBar/node_modules/react-native-firebase/ios/RNFirebase/RNFirebase.m -o /var/folders/1_/zbm5sxxj7rbgbvxqv5xdy7pr0000gp/T/tmp.JygzFQ2B/FooBar/ios/build/Build/Intermediates/Pods.build/Debug-iphonesimulator/RNFirebase.build/Objects-normal/x86_64/RNFirebase.o
In file included from /var/folders/1_/zbm5sxxj7rbgbvxqv5xdy7pr0000gp/T/tmp.JygzFQ2B/FooBar/node_modules/react-native-firebase/ios/RNFirebase/RNFirebase.m:1:
/var/folders/1_/zbm5sxxj7rbgbvxqv5xdy7pr0000gp/T/tmp.JygzFQ2B/FooBar/node_modules/react-native-firebase/ios/RNFirebase/RNFirebase.h:4:9: fatal error: 'React/RCTEventEmitter.h' file not found
#import <React/RCTEventEmitter.h>
        ^
1 error generated.

...node_modules/react-native-firebase/ios/RNFirebase/RNFirebase.h:4:9: fatal error: 'React/RCTEventEmitter.h' file not found

Why fix it here

It would be really great to have compatibility between RNFirebase and FirebaseUI.
There’s an official Android version of FirebaseUI, and Facebook is a rather popular login method, so unblocking a road towards a proper RNFirebaseUI package would be valuable for the whole community.

Root cause is obviously the over-complicated and ugly XCode build system, but maybe there’s a not too hard fix on your side.
I will raise an issue with FirebaseUI-iOS as they seem to be open to supporting non-frameworks build but obviously no guarantees or ETAs there.

Environment

$ uname -a
Darwin Redacted.local 16.6.0 Darwin Kernel Version 16.6.0: Fri Apr 14 16:21:16 PDT 2017; root:xnu-3789.60.24~6/RELEASE_X86_64 x86_64
$ xcodebuild -version
Xcode 8.3.3
Build version 8E3004b
$ pod --version
1.3.0.beta.2

"dependencies": {
	"react": "16.0.0-alpha.12",
	"react-native": "0.46.2",
	"react-native-firebase": "^2.0.3"
},

Author: Fantashit

5 thoughts on “RNFirebase doesn’t compile with use_frameworks!

  1. I’ve just been investigating this further and whilst I’ve resolved the issue with RNFirebase not being able to see React imports, this only got me to a bigger issue:

    Unfortunately it seems that Firebase is fundamentally broken when using the !use_frameworks flags and it’s being imported by a third party library, i.e. RNFirebase. This is discussed in some detail here: CocoaPods/CocoaPods#5368 and acknowledged by somebody at Google here: firebase/firebase-ios-sdk#58 (comment)

    FirebaseUI have got around this issue by actually embedding the Firebase dependencies within their library directly. This approach doesn’t work for us, as it would mean every app using RNFirebase would have every Firebase library added to it whether they’re using the functionality or not. This adds unnecessary bloat and is something we’re not keen to do.

    I’ve reached out to a contact at Firebase directly to see what we might be able to do in order to resolve this satisfactorily, but until then, I’m afraid that I don’t have a way of working around this issue.

  2. @nagad814 I have just updated the release notes to make it clear that you should still use cocoapods for the Firebase SDK, but not for react-native-firebase itself

  3. For anyone looking for a workaround with 5.x & use_framework! this days, add this to your Podfile

    post_install do |installer|
      # react-native-firebase need some adjustements  with use_frameworks!
      rnfirebase = installer.pods_project.targets.find { |target| target.name == 'RNFirebase' }
      rnfirebase.build_configurations.each do |config|
        # react-native-firebase HEADER_SEARCH_PATHS are not good
        # This is to avoid the error
        # 'Firebase.h' file not found with <angled> include; use "quotes" instead
        config.build_settings['HEADER_SEARCH_PATHS'] = '$(inherited) ${PODS_ROOT}/Headers/Public/**'
        # injecting `s.static_framework = true`
        # (should be in RNFirebase.podspec but since it's not, the code below is doing the same behavior)
        config.build_settings['MACH_O_TYPE'] = 'staticlib'
      end
    end
    
    pre_install do |installer|
      # workaround for https://github.com/CocoaPods/CocoaPods/issues/3289
      # to avoid 
      # [!] The 'Pods-ADM' target has transitive dependencies that include statically linked binaries: (FirebaseCore, FirebaseInstanceID, FirebaseDynamicLinks, and FirebaseMessaging)
      Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}
    end

    🎉 It took me 2 days to understand what I was doing but I think I got it right 🙂

  4. I used below script to automate #252 (comment)

    pre_install do |installer|
      installer.pod_targets.each do |pod|
        if pod.name.start_with?('RNFB')
          def pod.build_type;
            Pod::Target::BuildType.static_library
          end
        end
      end
    end

Comments are closed.