react-native-firebase
react-native-firebase copied to clipboard
[๐] The following Swift pods cannot yet be integrated as static libraries [has workaround / Need Expo instructions to close this]
[UPDATE: we have something that works below, but we need an Expo user to figure out how to correctly set two items in the Podfile in The Expo Way]
Issue
pod install
not working with the following error:
[!] The following Swift pods cannot yet be integrated as static libraries:
The Swift pod `FirebaseCoreInternal` depends upon `GoogleUtilities`, which does not define modules. To opt into those targets generating module maps (which is necessary to import them from Swift when building as static libraries), you may set `use_modular_headers!` globally in your Podfile, or specify `:modular_headers => true` for particular dependencies.
How to reproduce
-
expo init Test --npm
- Select "Bare workflow -> minimal"
-
cd Test
-
npm i @react-native-firebase/analytics @react-native-firebase/app
-
cd ios
-
pod install
- Error appears
If your prefer I created a repo: https://github.com/RodolfoGS/FirebaseCoreInternal-issue
-
git clone [email protected]:RodolfoGS/FirebaseCoreInternal-issue.git
-
cd FirebaseCoreInternal-issue/
-
npm i
-
cd ios
-
pod install
- Error happens
This happens with all Firebase dependences, I tested with:
- @react-native-firebase/analytics
- @react-native-firebase/app
- @react-native-firebase/crashlytics
- @react-native-firebase/dynamic-links
- @react-native-firebase/remote-config
Project Files
Javascript
Click To Expand
package.json
:
{
"name": "test",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"start": "expo start --dev-client",
"android": "expo run:android",
"ios": "expo run:ios",
"web": "expo start --web"
},
"dependencies": {
"@react-native-firebase/analytics": "^15.0.0",
"@react-native-firebase/app": "^15.0.0",
"expo": "~45.0.0",
"expo-splash-screen": "~0.15.1",
"expo-status-bar": "~1.3.0",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-native": "0.68.2",
"react-native-web": "0.17.7"
},
"devDependencies": {
"@babel/core": "^7.12.9"
},
"private": true
}
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:
# N/A
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:
- [x] 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:-
15.0.0
-
-
Firebase
module(s) you're using that has the issue:-
@react-native-firebase/analytics
-
-
Are you using
TypeScript
?-
Y/N
&VERSION
-
- ๐ Check out
React Native Firebase
andInvertase
on Twitter for updates on the library.
(re-posting/moving here, from #6323)
@RodolfoGS thanks posting a repro!
What happens if you affect this:
https://github.com/RodolfoGS/FirebaseCoreInternal-issue/blob/4c626b5cdcac40ec99a1c2b3fead2ae5db61670e/ios/Podfile#L16
Experiments to run:
1- make that line say nothing except use_frameworks!
(that is: no linkage stuff after)
2- make that line say use_frameworks! :linkage => :dynamic
(note! This should be same result as experiment 1, dynamic is the default)
3- make that line say use_frameworks! :linkage => :static
I'm not sure how exactly you would configure that in Podfile.properties.json
so that you are doing it The Expo Way but based on the results of the experiments above we may have a working solution for cocoapods, then (assuming we find one that works) we can back that in to Podfile.properties.json
Note that use_frameworks interacts with Hermes and Flipper and react-native 0.69 with varying degrees of success depending on static or dynamic linkage. See https://github.com/reactwg/react-native-releases/discussions/21#discussioncomment-2924919 In general you should disable hermes and flipper if you use use_frameworks right now, and you should be on react-native 0.68.2 or lower, 0.69.0 won't work. (0.69.1 will have hermes and 0.69.1 working, but flipper will still not work pending a PR in the area...See https://github.com/reactwg/react-native-releases/discussions/23#discussioncomment-3012014)
Results:
-
pod install
works in demo repo without another library installed, but failed if you install another library, likereact-native-google-mobile-ads
with the following error:
[!] The 'Pods-Test' target has transitive dependencies that include statically linked binaries: (__path__/Test/ios/Pods/Google-Mobile-Ads-SDK/Frameworks/GoogleMobileAdsFramework-Current/GoogleMobileAds.xcframework and __path__/Test/ios/Pods/GoogleUserMessagingPlatform/Frameworks/Release/UserMessagingPlatform.xcframework)
- Same result as 1
- Same as 1
So that actually seems like 1 will work for react-native-firebase, I think that's a positive result and figuring out how to preserve that result while using the default Expo podfile and making it happen with Podfile.properties.json would be useful as a follow-up.
But now we move back to the other repo (mobile ads) to see what's going on there. I wonder if you reached in to node_modules/react-native-google-mobile-ads/ and tweaked the .podspec
file here:
https://github.com/invertase/react-native-google-mobile-ads/blob/5d2048b530b798740c9fed392772568f909dd6b2/RNGoogleMobileAds.podspec#L43-L48
By setting $RNGoogleMobileAdsAsStaticFramework = true
in your Podfile if that would let it work :thinking: - that was the solution for react-native-firebase and it appears to be implemented but just not documented in react-native-google-mobile-ads
@RodolfoGS $RNGoogleMobileAdsAsStaticFramework = true
in the Podfile
then reinstalling pods was the key for me. I reproduce your error when I do not have that set to true, and I build react-native-firebase + react-native-google-mobile-ads (with podspec patch to Google-Mobile-Ads-SDK 9.6.0!) with it.
I don't have time to play with Expo right now, but for Expo people on react-native-firebase:
1- need to determine what to put in Podfile.properties.json so it correctly sets use_frameworks! :linkage => :dynamic
Google Ads needs the Podfile variable set for static builds then it should all work
I tested that and react-native-mobile-ads
could be installed now with the combination of:
-
googleMobileAds: 9.6.0
+ -
use_frameworks!
+ -
$RNGoogleMobileAdsAsStaticFramework = true
But I have problems with another libraries, maybe because they doesn't have the "$RNGoogleMobileAdsAsStaticFramework" hack.
The two libraries that I have the same problem are:
- react-native-applovin-max
- react-native-flurry-sdk
But I think that another users could have more issues with another libraries.
In the meanwhile I will stay in 14.11.1
Interesting, you could check their podspec and try to patch it, that variable that we add does a really simple change and it is patch-patchable really trivially as a test...
The specific change in the affected libraries is just to add this:
s.static_framework = true
(the s.
is a variable in the ruby block, it may be called something different but it is hopefully obvious whatever it is)
how do i fix this? which version should i downgrade to
@lockieluke You don't specify what the "this" is. There are a few problems depending on whether what you want is "to use react-native new architecture", or "I want to use hermes on iOS" or "I'm on Expo" or any of a number of things. The comments above contain a lot of detail. You can help work the problem and most likely use react-native-firebase v15 with the changes detailed above
Or you can stay on react-native-firebase v14.whatever-is-current and it may work for you, depending on what "this" is in
how do i fix this?
https://stackoverflow.com/help/how-to-ask
it fails to build if i use the latest version of react-native-firebase
That is still a vastly incomplete description of the problem. What version of react-native are you on? Do you use Expo? Do you also use react-native-google-mobile-ads? Do you use Hermes?
Given two comments unable to completely specify your problem, thus my inability to help really, I'm going to suggest staying with v14 is probably best
Does anyone know if there is a way to resolve this under the managed workflow using EAS?
@nbonatsakis I'm not sure how to do it in Expo terms but if you can:
- determine what to put in Podfile.properties.json so it correctly sets use_frameworks! :linkage => :dynamic
and
- figure out how to set $RNFirebaseAsStaticFramework = true
and
- set this variable for react-native-google-mobile-ads if you use that:
$RNGoogleMobileAdsAsStaticFramework = true
...and there are no other native libraries to patch then... should work? It's relatively easy to do that in a non-Expo context but I don't have Expo experience so I'm not sure
Otherwise, v14 here is already aging but it was state of the art just a month ago or so, open source is messy and compatibility is difficult but if you can't answer the "how" for 1 and 2 above, someone surely will before too long (I hope!)
Hmm. I pre-built the project and changed the Podfile to include use_modular_headers!
and that seemed to work. I was going to write a quick EAS config plugin to do this modification, any concerns about fixing it that way? (fewer steps).
I'm a very practical person with a strict requirement for automated solutions. If you can automate something that works 100% of the time every time, that works for me and we'll all do a happy dance!
Users have noted, when trying use_frameworks!
and react-native 0.69.1 that builds to real devices will fail because the patches in 0.69.1 are incompatible with bitcode. Xcode 14 will deprecate bitcode, so simply disabling it appears to a reasonable solution, then react-native 0.69.1 is accessible in combo with the Podfile variables above
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['ENABLE_BITCODE'] = 'NO'
end
end
Temporary Workaround: This might be an issue with one of the new versions that was shipped. I was encountering the same error in 15.1.1
(was saying FirebaseCore instead of FirebaseCoreInternal for me) and once I downgraded to 14.11.0
, the ios build started working without any issues.
This fixed it for me:
- Add
expo-build-properties
package
expo add expo-build-properties
- Update
app.json
to include:
{
"expo": {
"plugins": [
[
"expo-build-properties",
{
"ios": {
"useFrameworks": "static"
}
}
]
]
}
}
Users have noted, when trying
use_frameworks!
and react-native 0.69.1 that builds to real devices will fail because the patches in 0.69.1 are incompatible with bitcode. Xcode 14 will deprecate bitcode, so simply disabling it appears to a reasonable solution, then react-native 0.69.1 is accessible in combo with the Podfile variables aboveinstaller.pods_project.targets.each do |target| target.build_configurations.each do |config| config.build_settings['ENABLE_BITCODE'] = 'NO' end end
mikehardy I have the same issue with bitecode but when i'll use your solution I get another error Undefined symbol: _OBJC_CLASS_$_FIRAnalytics
With apologies I'm traveling right now so haven't had time to do another batch of resolution / developer-experience-smoothing here, or in the related repo where I test things (discussion at https://github.com/mikehardy/rnfbdemo/issues/10)
This might be an issue with one of the new versions that was shipped. I was encountering the same error in
15.1.1
(was saying FirebaseCore instead of FirebaseCoreInternal for me) and once I downgraded to14.11.0
, the ios build started working without any issues.
This works ๐
Downgrading of course works, but that's the same as saying "the new version is a bit difficult so not using it avoids the difficulty", in other words it is a tautology --> 1 = 1. For anyone that needs to do this I do understand, but please pay attention to this issue for progress so you can successfully move on to future version versus being stuck forever on the old stuff
@harterc1 Thanks for this!
Also needed to add this to the podfile manually to make it work (source):
installer.pods_project.targets.each do |target|
if target.name == 'RCT-Folly'
target.build_configurations.each do |config|
config.build_settings['HEADER_SEARCH_PATHS'] = "$(inherited) ${PODS_ROOT}/fmt/include"
end
end
end
I have to figure away to add this to the podfile via expo/eas to make the build process work.
- EDIT * Nevermind, the pods installation still fails... :/
Compiling expo-dev-menu Pods/expo-dev-menu ยป EventHandlerRegistry.cpp
โบ Compiling expo-dev-menu Pods/expo-dev-menu ยป EXDevMenuAppInfo.m
โ (../../node_modules/expo-dev-menu/ios/EXDevMenuAppInfo.m:3:9)
1 | // Copyright 2015-present 650 Industries. All rights reserved.
2 | #import "EXDevMenuAppInfo.h"
> 3 | #import <EXDevMenu-Swift.h>
| ^ 'EXDevMenu-Swift.h' file not found
4 | #import <EXManifests/EXManifestsManifestFactory.h>
5 |
6 | @implementation EXDevMenuAppInfo
I'm able to install pods with
pod 'GoogleUtilities', :modular_headers => true
but I'm getting error when I'm trying to build app
You may not need to use use_frameworks! or use_modular_headers! because it's getting conflict with use_flipper
You can add the following without using them:
pod 'Firebase', :modular_headers => true pod 'FirebaseCoreInternal', :modular_headers => true pod 'GoogleUtilities', :modular_headers => true #....add any library need headers
Don't say thank you
I was not able to run a project using React Native 0.69.1 and firebase 15.1.1 on an M1 Mac. I tried to follow the docs and also most of the recommendations here, but I had no luck.
Anyone with a successful experience?
I'm travelling and have not had a chance to move my demo forward from 0.69.0 but my make demo script (should have a link above?) Definitely worked on M1. It will need an update for 0.69.1, I'll get it as soon as I can, until then I'd look at exactly what it is doing and stay on 0.69.0 for now with the patch-package patch it uses
Any chance to make it work without use_frameworks!
? Using it gives conflicts with some libraries like react-native-reanimated
I was able to solve the issue by adding the following to the pod file
use_frameworks!
$RNFirebaseAsStaticFramework = true
And of course to disable the flipper
# use_flipper!()
It works great on test development but getting an error when deploying it on a physical IOS device by cable
Error => -U and -bitcode_bundle (Xcode setting ENABLE_BITCODE=YES) cannot be used together
So I'm kinda stuck there because of using of use_frameworks
I fixed the issue, I disabled use_frameworks and just put the following
pod 'Firebase', :modular_headers => true
pod 'FirebaseCore', :modular_headers => true
pod 'GoogleUtilities', :modular_headers => true
$RNFirebaseAsStaticFramework = true
And keep using flipper
use_flipper!()
I tested it on both test and real devices and it works great ๐
What do you think of my solution?
See full answer here if you wanted to use rich content notification.
@Shrroy are you using @react-native-firebase/messaging
?