ios - 使用 cocoapods for firebase 的 React-native 共享扩展问题

标签 ios xcode firebase react-native cocoapods

我正在尝试使用基于 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 调试扩展时,日志显示如上所示的错误。

有什么想法吗?谢谢

最佳答案

按照标准安装说明进行操作后,我能够正常工作,请确保执行以下操作:

  1. 在您的扩展的构建阶段链接 libRNFirebase.a。此外,确保 libPods-{YOUR_EXTENSION_NAME}.a 也已链接。
  2. 为您的主应用设置 GoogleService-Info.plist 目标 以及右侧面板中的分享扩展。
  3. 在您的共享扩展程序的build设置 > 其他链接器标志中, 确保添加 $(inherited)
  4. 在您的共享扩展 .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/

相关文章:

ios - 我的弹出窗口中没有数据

ios - 通过数组 Firebase 实现 TableView 图像异步

ios - 如何避免此处搜索栏和表格 View 之间的额外间隙并在它们之间放置分隔符?

ios - 应用程序未运行时监听信标

ios - SKVideoNode 仅在节点或相机移动时在 SCNScene 中渲染

ios - 警告 : will never be excuted

ios - Swift 全屏问题?

c# - Firebase 流式 REST 连接是否计入并发连接限制?

ios - 使用阵列 SWIFT 从 child 那里接收 Firebase 快照

android - Firebase 数据库 ArrayList 未排序