Open marcoizzo opened 6 years ago
Same issue here.
Did you include the RNFirebase Project in your extension's build target Link Binary With Libraries? It seems like Firebase is installed correctly but you native RNFirebase Project is missing...
I've solved with the creation of an app group between the app and the extension
@marcoizzo can you explain me exactly what you mean? I am not really sure how to do this :)
@BigPun86 you have to create an app group. To do this:
Then add linked framework and libraries required (libRNFirebase.h) under general tab
I hope this useful :)
@marcoizzo Unfortunately it didn´t help. But thanks for your explanation. I am using Crashlytics aas well in my pods. I tried to add both libRNFirebase & lib..Crashlytics. I still receive the errors and it wont build my project. I f i remove crashlytics and firebase as linked libraries it will build, but then the app hangs as soon as i share something (URL or Image). Any ideas how to fix that? I mean, do you think this is because i didn´t link CrashLytics and Firebase?
@BigPun86 what's the error during building? Anyway, you have to include Firebase and CrashLytics in your extension if you have to use them in your code
@marcoizzo this is the error i am getting:
This is how my PodFile looks like:
target 'SomeApp' do
pod 'FirebaseMessaging'
pod 'Fabric'
pod 'Crashlytics'
target 'SomeAppShare' do
inherit! :search_paths
pod 'FirebaseMessaging'
pod 'Fabric'
pod 'Crashlytics'
end
target 'SomeAppTests' do
inherit! :search_paths
end
end
@BigPun86 Do you have added -ObjC
and -lc++
as linker flags?
@marcoizzo i added it to the Share Target, yes.
@BigPun86 mmm... it seem that the problem is Fabric, but I have never used it so I don't know... Try to remove it in your extension to understand if really crashlytics is the issue
@marcoizzo now i am getting some React related issues. Maybe u can show me how you have set up your Header Search Path?
This is how mine looks right now:
This is mine
@marcoizzo many thanks, i will check it. So actually your Header Search stuff is exactly the same as the one you use for your main target app?
@BigPun86 Yep!
@marcoizzo Any more information you can share on your successful setup? I would really appreciate any help you can give towards adding rnfirebase!
I've previously got the share extension working without rnfirebase. Below is some information about my attempt to integrate rnfirebase.
Share Extension
ShareExtension.m
Header Search Paths
Linked Frameworks and Libraries
Main App
Header Search Paths
Linked Frameworks and Libraries
Podfile
@daviswhitehead could you atleast build without issues, or does this already fail?
I can build successfully without trying to integrate rnfirebase. But when I do, I get the following error, which I believe you were seeing as well right @BigPun86 ?
@daviswhitehead yeah, i had exactly the same issue. i cant remember what exactly i have done which fixed it...but i think it was enabling AppGroups and/or first cleaning and then building the ShareExtension target/app, maybe you can just try that. If not i hope my setup will help you:
Linked Libraries and Header Search Path setup of the main App:
Linked Libraries and Header Search Path setup of the Share Extension:
@BigPun86 what does your appgroup look like? does this look correct to you? (both the main app and extension look the same)
I'm getting the same error regardless of if I have App Groups on or off. Any ideas?
@daviswhitehead yes, but you have to enable it for both, the ShareExtension & the Main App. Then run pod install again and maybe also react-native link...
Yep I've enabled for both and am getting the same error.
@daviswhitehead did you run pod install & react-native link after your changes too?
Unfortunately, yes I have and am still on that same error.
I think it's failing before hitting anything related to App Groups. I get the same error when App Groups is off for both (main and share extension) targets.
I'm not super familiar with xcode or native iOS dev, but it seems like libRNFirebase.a is not able to find all the nested references. My code seems to be failing at the #import
I was able to get the firebase pods linked by removing all pods under the extension and adding the line inherit! :complete
.
However, the extension is now failing at [FIRApp configure];
in the ShareExtension.m file. Upon debugging, my thread get's killed
and I get the following output
Message from debugger: Terminated due to signal 6
Any ideas @BigPun86 or @marcoizzo ?
Figured it out! I solved the latest problem by adding the GoogleService-Info.plist file into the ShareExtension folder like so.
My podfile looks like this
@daviswhitehead I'm experiencing the same linker error you were at first:
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_FIRMessaging", referenced from:
objc-class-ref in libRNFirebase.a(RNFirebaseMessaging.o)
"_OBJC_CLASS_$_FIRTransactionResult", referenced from:
objc-class-ref in libRNFirebase.a(RNFirebaseDatabase.o)
"_OBJC_CLASS_$_FIRDatabase", referenced from:
objc-class-ref in libRNFirebase.a(RNFirebaseDatabase.o)
"_OBJC_CLASS_$_FIRAnalyticsConfiguration", referenced from:
objc-class-ref in libRNFirebase.a(RNFirebaseAnalytics.o)
"_OBJC_CLASS_$_FIRAnalytics", referenced from:
objc-class-ref in libRNFirebase.a(RNFirebaseAnalytics.o)
"_OBJC_CLASS_$_FIRGitHubAuthProvider", referenced from:
objc-class-ref in libRNFirebase.a(RNFirebaseAuth.o)
"_OBJC_CLASS_$_FIREmailAuthProvider", referenced from:
objc-class-ref in libRNFirebase.a(RNFirebaseAuth.o)
"_OBJC_CLASS_$_FIRFacebookAuthProvider", referenced from:
objc-class-ref in libRNFirebase.a(RNFirebaseAuth.o)
"_OBJC_CLASS_$_FIRActionCodeSettings", referenced from:
objc-class-ref in libRNFirebase.a(RNFirebaseAuth.o)
"_OBJC_CLASS_$_FIRInstanceID", referenced from:
objc-class-ref in libRNFirebase.a(RNFirebaseInstanceId.o)
objc-class-ref in libRNFirebase.a(RNFirebaseMessaging.o)
"_OBJC_CLASS_$_FIRAuth", referenced from:
objc-class-ref in libRNFirebase.a(RNFirebaseAuth.o)
"_OBJC_CLASS_$_FIRTwitterAuthProvider", referenced from:
objc-class-ref in libRNFirebase.a(RNFirebaseAuth.o)
"_OBJC_CLASS_$_FIROptions", referenced from:
objc-class-ref in libRNFirebase.a(RNFirebase.o)
"_OBJC_CLASS_$_FIROAuthProvider", referenced from:
objc-class-ref in libRNFirebase.a(RNFirebaseAuth.o)
"_OBJC_CLASS_$_FIRApp", referenced from:
objc-class-ref in ShareExtension.o
objc-class-ref in libRNFirebase.a(RNFirebaseAuth.o)
objc-class-ref in libRNFirebase.a(RNFirebase.o)
objc-class-ref in libRNFirebase.a(RNFirebaseUtil.o)
"_OBJC_CLASS_$_FIRPhoneAuthProvider", referenced from:
objc-class-ref in libRNFirebase.a(RNFirebaseAuth.o)
"_OBJC_CLASS_$_FIRGoogleAuthProvider", referenced from:
objc-class-ref in libRNFirebase.a(RNFirebaseAuth.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Do you recall if there were any steps you took to resolve it that weren't mentioned in this thread?
The extension portion of my podfile looks like this:
target 'ShareExtension' do
inherit! :complete
end
Linker flags are set correctly.
In my header search paths for the extension I have
$(inherited)
$(SRCROOT)/../node_modules/react-native-firebase/ios/RNFirebase
$(SRCROOT)/../node_modules/react-native-share-extension/ios
Under Build Phases > Link Binary with Libraries I have libRNFirebase.a
and libPods-ShareExtension.a
Does anything else come to mind that I might try?
Interestingly enough when I remove firebase I am able to build but get a runtime error related to firebase, even if I don't import it in ShareExtension.m
For anyone struggling with this issue. After following the standard installation instructions, make sure you do the following:
1) Link libRNFirebase.a
in your Extension's Build Phases.
Also, make sure that libPods-{YOUR_EXTENSION_NAME}.a
is linked as well.
2) Set the GoogleService-Info.plist target for both your main app and your share extension in the right panel.
3) In your share extension's Build Settings > Other Linker Flags, make sure you add $(inherited)
4) In your Share Extension .m
file, make sure you import Firebase and configure it there as well!
#import <Firebase.h>
- (UIView*) shareView {
NSURL *jsCodeLocation;
[FIRApp configure];
…
}
@AndrewHenderson Do you know if it is possible to authenticate with firebase from the main app and some how pass the authentication to the share extension? (I don't want to ask the user to do login again)
@i25878427 Use react-native-shared-group-preferences. For iOS you'll need to create an "App Group" and give both your app and the extension permission. This has to be done in Xcode. The install steps should cover everything.
@AndrewHenderson Thanks for the help :-). I already have "App Group" installed and I was able to share data between the main app and the share extension.
Maybe my question is more firebase related. I don't know what should I share with the share extension from the main app to make the share extension authenticate with firebase, so I can read/write to firebase database.
@i25878427 I've found that the Share extension has its own scope and any modules have separate instances — so your Firebase instance would probably have to be initialized for both.
The only data I've been able to share is storing strings in the App Group.
You're better off asking these questions in https://github.com/invertase/react-native-firebase. They also have their own channel on Discord. Good luck! 😄
@AndrewHenderson Thanks! I will try using their channel :-)
not totally sure how this works technically, but I was able to authenticate with firestore through the share extension in the same way I do within my main app. Not sure if it's any different for firebase but would guess not.
this.authSubscription = firebase.auth().onAuthStateChanged((user) => { this.setState((previousState) => { return { ...previousState, loading: false, user: user, } }) });
That seems right. I’d expect you’d need to authenticate the same way, but that there would be separate configured firebase instances — so they would not share a session.
Did you have to auth through share extension separately? Do you have to reauthenticate in the share extension every time?
In your share extension's Build Settings > Other Linker Flags, make sure you add $(inherited)
Adding ${inherited}
fixed my problem. Thanks for your info, @AndrewHenderson
@daviswhitehead I'm experiencing the same linker error you were at first:
Undefined symbols for architecture x86_64: "_OBJC_CLASS_$_FIRMessaging", referenced from: objc-class-ref in libRNFirebase.a(RNFirebaseMessaging.o) "_OBJC_CLASS_$_FIRTransactionResult", referenced from: objc-class-ref in libRNFirebase.a(RNFirebaseDatabase.o) "_OBJC_CLASS_$_FIRDatabase", referenced from: objc-class-ref in libRNFirebase.a(RNFirebaseDatabase.o) "_OBJC_CLASS_$_FIRAnalyticsConfiguration", referenced from: objc-class-ref in libRNFirebase.a(RNFirebaseAnalytics.o) "_OBJC_CLASS_$_FIRAnalytics", referenced from: objc-class-ref in libRNFirebase.a(RNFirebaseAnalytics.o) "_OBJC_CLASS_$_FIRGitHubAuthProvider", referenced from: objc-class-ref in libRNFirebase.a(RNFirebaseAuth.o) "_OBJC_CLASS_$_FIREmailAuthProvider", referenced from: objc-class-ref in libRNFirebase.a(RNFirebaseAuth.o) "_OBJC_CLASS_$_FIRFacebookAuthProvider", referenced from: objc-class-ref in libRNFirebase.a(RNFirebaseAuth.o) "_OBJC_CLASS_$_FIRActionCodeSettings", referenced from: objc-class-ref in libRNFirebase.a(RNFirebaseAuth.o) "_OBJC_CLASS_$_FIRInstanceID", referenced from: objc-class-ref in libRNFirebase.a(RNFirebaseInstanceId.o) objc-class-ref in libRNFirebase.a(RNFirebaseMessaging.o) "_OBJC_CLASS_$_FIRAuth", referenced from: objc-class-ref in libRNFirebase.a(RNFirebaseAuth.o) "_OBJC_CLASS_$_FIRTwitterAuthProvider", referenced from: objc-class-ref in libRNFirebase.a(RNFirebaseAuth.o) "_OBJC_CLASS_$_FIROptions", referenced from: objc-class-ref in libRNFirebase.a(RNFirebase.o) "_OBJC_CLASS_$_FIROAuthProvider", referenced from: objc-class-ref in libRNFirebase.a(RNFirebaseAuth.o) "_OBJC_CLASS_$_FIRApp", referenced from: objc-class-ref in ShareExtension.o objc-class-ref in libRNFirebase.a(RNFirebaseAuth.o) objc-class-ref in libRNFirebase.a(RNFirebase.o) objc-class-ref in libRNFirebase.a(RNFirebaseUtil.o) "_OBJC_CLASS_$_FIRPhoneAuthProvider", referenced from: objc-class-ref in libRNFirebase.a(RNFirebaseAuth.o) "_OBJC_CLASS_$_FIRGoogleAuthProvider", referenced from: objc-class-ref in libRNFirebase.a(RNFirebaseAuth.o) ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
Do you recall if there were any steps you took to resolve it that weren't mentioned in this thread?
The extension portion of my podfile looks like this:
target 'ShareExtension' do inherit! :complete end
Linker flags are set correctly.
In my header search paths for the extension I have
$(inherited) $(SRCROOT)/../node_modules/react-native-firebase/ios/RNFirebase $(SRCROOT)/../node_modules/react-native-share-extension/ios
Under Build Phases > Link Binary with Libraries I have
libRNFirebase.a
andlibPods-ShareExtension.a
Does anything else come to mind that I might try?
Interestingly enough when I remove firebase I am able to build but get a runtime error related to firebase, even if I don't import it in ShareExtension.m
I am facing the same issue. @emilefleming did you end up resolving this ? @AndrewHenderson I followed all the instructions listed as well.
Here is how my pod file looks -
#import <Foundation/Foundation.h>
#import "ReactNativeShareExtension.h"
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import <React/RCTLog.h>
#import <Firebase.h>
@interface ShareExt : ReactNativeShareExtension
@end
@implementation ShareExt
RCT_EXPORT_MODULE();
- (UIView*) shareView {
NSURL *jsCodeLocation;
[FIRApp configure];
jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
moduleName:@"ShareExtApp"
initialProperties:nil
launchOptions:nil];
rootView.backgroundColor = nil;
// Uncomment for console output in Xcode console for release mode on device:
RCTSetLogThreshold(RCTLogLevelInfo - 1);
return rootView;
}
@end
Any help appreciated!!
Hi guys,
thanks for this component.
I'm trying to implement a share extension with a firebase-based app. So I have created a pod file and generated a .xcworkspace project.
I followed all installation tutorial and all seem ok, but when I try to launch the extension Xcode console says:
RNFirebase core module was not found natively on iOS, ensure you have correctly included the RNFirebase pod in your projects 'Podfile' and have run 'pod install'.
This is my pod file:
And this my TogetherShareEx.m
I have also addedd:
Any idea? Thanks