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
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
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.
$ 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"
},
@Salakar I will try those steps, I've already spent three full days trying everything i could think of, but seems like you've just given me some fresh ideas.
Is anyone else able to reproduce it using the script I've provided?
It'd give us an idea of whether this bug affects only certain XCode / Mac OS versions.
Hi, Any update on this issue?
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: https://github.com/CocoaPods/CocoaPods/issues/5368 and acknowledged by somebody at Google here: https://github.com/firebase/firebase-ios-sdk/issues/58#issuecomment-312885671
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.
As there's nothing we're able to do and the docs have been updated I'll close this one. Once we have any further feedback from Firebase we can re-open.
It seems this issue is fixed in cocoa pods v4 https://github.com/firebase/firebase-ios-sdk/issues/58#issuecomment-335806897. Is it time to reopen this issue or are there still blocking things?
+1
+1
Please open this.. i have apps waiting for this.
@nagad814 check latest release notes.
I did read through them. i am not clear should i use cocoapods or not. if not how to install RNFB
@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
@Salakar @chrisbianca If I understand this correctly, then it seems like the documentation should be updated then?
https://github.com/invertase/react-native-firebase-docs/blob/9b6b80476aadf0c1f3a51124b74171e278bba593/docs/installation/ios.md#ios-installation still mention that use_frameworks!
enabled doesn't work.
For anyone still having this problem, I found my solution here: https://stackoverflow.com/a/53178800
In Xcode 10, I had to switch my workspace settings to "Legacy Build System"
Another possible workaround, from a different library, is to try adding this to podspecs - fixed a build elsewhere without reverting to legacy build:
s.static_framework = true
https://github.com/transistorsoft/react-native-background-geolocation/issues/708#issuecomment-488881314
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 :)
@Salakar this might be interesting - @MoOx - this is fully working for you?
I'm interested for a couple reasons - one because if it doesn't cost too much in maintenance more flexibility is better, but also because your header search paths thing might be the fix I need for #2163 that I'm currently working around with the brutal hack of a header copy in postinstall...
@MoOx I examined this with @Salakar and the underlying issue should be resolved in v6 but for v5 if you'd like to propose a PR to the actual podspec we could get this done and released. I'm going to examine at least the header paths issue for the above mentioned #2163
@mikehardy PR made that allows me to cleanup my podfile! (not more tricks needed) https://github.com/invertase/react-native-firebase/pull/2235
released 5.5.4 with use_frameworks support today!
`
error Failed to build iOS project. We ran "xcodebuild" command but it exited with error code 65. To debug build logs further, consider building your app with Xcode.app, by opening hotlap.xcworkspace
2019-07-03 02:10:40.251 xcodebuild[90954:11082035] DTDeviceKit: deviceType from 6834c928b75d94cf9741389e8b65c368f2be1b44 was NULL
2019-07-03 02:10:40.301 xcodebuild[90954:11082034] DTDeviceKit: deviceType from 6834c928b75d94cf9741389e8b65c368f2be1b44 was NULL
* BUILD FAILED *
The following commands produced analyzer issues:
Analyze /Users/huanvu/Documents/hotlap-react/node_modules/react-native/ReactCommon/jsi/jsi.cpp normal x86_64
Analyze /Users/huanvu/Documents/hotlap-react/node_modules/react-native/ReactCommon/yoga/yoga/Yoga.cpp normal x86_64
Analyze /Users/huanvu/Documents/hotlap-react/node_modules/react-native/React/Base/RCTModuleMethod.mm normal x86_64
(3 commands with analyzer issues)
The following build commands failed:
CompileC /Users/huanvu/Documents/hotlap-react/ios/build/hotlap/Build/Intermediates.noindex/RNFirebase.build/developmentDebug-iphonesimulator/RNFirebase.build/Objects-normal/x86_64/RNFirebaseFunctions.o /Users/huanvu/Documents/hotlap-react/node_modules/react-native-firebase/ios/RNFirebase/functions/RNFirebaseFunctions.m normal x86_64 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)
`
@mikehardy I'm having trouble with 5.5.4 (with 6.3.0 firebase pods) still. Any clue what this could be about?
Whenever I have an iOS build problem, before proceeding further, I do a deep cleaning. Can you try npm i 鈥攕ave-dev react-native-clean-project && npx react-native clean-project-auto
, or (even better since it fixes an iOS thing where DerivedData still wasn鈥檛 deleted) https://github.com/pmadruga/react-native-clean-project/pull/19 - npm i 鈥攕ave-dev 鈥榞it+https://github.com/mikehardy/react-native-clean-project.git#xcode-caches' && npx react-native clean-project-auto
?
@mikehardy deep cleaning with those scripts did not work for me.
I was able to successfully build by unlinking react-native-firebase and adding the pod for RNFirebase to my Podfile like here: https://github.com/invertase/react-native-firebase/pull/2235#issuecomment-507961261
... but the app crashed on launch with not much information that I could decipher because xcode. Will keep digging.
Interesting - I think for use_frameworks you would need to use react-native-firebase integrated by pods, so that makes sense (and we should mention that in the docs I think, but first we need to know it works - use_frameworks support is new, and it actually breaks again in RN0.60 because of an upstream react-native issue but that鈥檚 another story
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.
I used below script to automate https://github.com/invertase/react-native-firebase/issues/252#issuecomment-525430121
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
Most helpful comment
For anyone looking for a workaround with 5.x &
use_framework!
this days, add this to your Podfile馃帀 It took me 2 days to understand what I was doing but I think I got it right :)