【问题标题】:Issue with React-native share extension with cocoapods for firebase使用 cocoapods for firebase 的 React-native 共享扩展问题
【发布时间】:2018-01-19 11:23:04
【问题描述】:

我正在尝试使用基于 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)”
  • 在标头搜索路径中添加了“$(SRCROOT)/../node_modules/react-native-firebase/ios/RNFirebase”

结果是创建了扩展,但是当我尝试共享某些内容时,什么也没有发生。在使用 Xcode 调试扩展时,日志显示上面显示的错误。

有什么想法吗?谢谢

【问题讨论】:

  • 我也有类似的问题
  • 有人帮助我们! :)
  • 现在我放弃了 Firebase 并使共享扩展尽可能轻。通过github.com/alinz/react-native-swiss-knife(在后台使用NSUserDefaults)将数据传递给主应用程序。
  • 我不能省略firebase,它需要在firestore上进行身份验证、存储文件和信息:(
  • 遇到同样的问题。安装 Firebase 后,主应用程序中的一切都按预期工作,但不再安装共享扩展。有更新吗?

标签: ios xcode firebase react-native cocoapods


【解决方案1】:

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

  1. 在扩展的构建阶段链接libRNFirebase.a。另外,请确保 libPods-{YOUR_EXTENSION_NAME}.a 也已链接。
  2. 为您的两个主应用设置 GoogleService-Info.plist 目标 以及右侧面板中的共享扩展程序。
  3. 在您的共享扩展的构建设置 > 其他链接器标志中, 确保添加 $(inherited)
  4. 在您的共享扩展 .m 文件中,确保导入 Firebase 并在那里进行配置!

有关详细信息,请参阅以下 GitHub 线程:https://github.com/alinz/react-native-share-extension/issues/79

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多