我正在尝试使用基于 firebase 的应用程序实现共享扩展。所以我创建了一个 pod 文件并生成了一个 .xcworkspace 项目。
我正在使用 [react-native-share-extension][1]。按照所有安装教程进行操作,一切似乎都正常,但是当我尝试启动扩展 Xcode 控制台时说:
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'.
这是我的 pod 文件:
target 'Together' do
# Pods for Together
pod 'Firebase/Core'
pod 'Firebase/Auth'
pod 'Firebase/Firestore'
pod 'Firebase/Messaging'
pod 'Firebase/Storage'
pod "QBImagePickerController"
end
target 'TogetherShareEx' do
# Pods for TogetherShareEx
pod 'Firebase/Core'
pod 'Firebase/Auth'
pod 'Firebase/Firestore'
pod 'Firebase/Storage'
end
这是我的 TogetherShareEx.m:
#import <Foundation/Foundation.h>
#import "ReactNativeShareExtension.h"
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import <React/RCTLog.h>
#import <Firebase.h>
@interface TogetherShareEx : ReactNativeShareExtension
@end
@implementation TogetherShareEx
RCT_EXPORT_MODULE();
- (UIView*) shareView {
NSURL *jsCodeLocation;
[FIRApp configure];
jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
moduleName:@"TogetherShareEx"
initialProperties:nil
launchOptions:nil];
rootView.backgroundColor = nil;
return rootView;
}
@end
我还添加了这些:
- 在其他链接器标志中添加了“$(inherited)”
- 在 header 搜索路径中添加了“$(SRCROOT)/../node_modules/react-native-firebase/ios/RNFirebase”
结果是创建了扩展程序,但是当我尝试共享某些内容时,没有任何反应。在使用 Xcode 调试扩展时,日志显示如上所示的错误。
有什么想法吗?谢谢
最佳答案
按照标准安装说明进行操作后,我能够正常工作,请确保执行以下操作:
- 在您的扩展的构建阶段链接
libRNFirebase.a
。此外,确保libPods-{YOUR_EXTENSION_NAME}.a
也已链接。 - 为您的主应用设置 GoogleService-Info.plist 目标 以及右侧面板中的分享扩展。
- 在您的共享扩展程序的build设置 > 其他链接器标志中, 确保添加 $(inherited)
- 在您的共享扩展
.m
文件中,确保导入 Firebase 并在那里进行配置!
有关详细信息,请参阅以下 GitHub 线程:https://github.com/alinz/react-native-share-extension/issues/79
关于ios - 使用 cocoapods for firebase 的 React-native 共享扩展问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48340002/