简体   繁体   English

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

[英]Issue with React-native share extension with cocoapods for firebase

I'm trying to implement a share extension with a firebase-based app. 我正在尝试使用基于firebase的应用程序实现共享扩展。 So I have created a pod file and generated a .xcworkspace project. 所以我创建了一个pod文件并生成了一个.xcworkspace项目。

I'm using [react-native-share-extension][1]. 我正在使用[react-native-share-extension] [1]。 Followed all installation tutorial and all seem ok, but when I try to launch the extension Xcode console says: 遵循所有安装教程,一切似乎都没问题,但是当我尝试启动扩展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'.

This is my pod file: 这是我的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

And this my TogetherShareEx.m: 这是我的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

I have also added these: 我还添加了以下内容:

  • added '$(inherited)' in Other Linker Flags 在其他链接器标志中添加了'$(inherited)'
  • added '$(SRCROOT)/../node_modules/react-native-firebase/ios/RNFirebase' in Header Search Paths 在标题搜索路径中添加了'$(SRCROOT)/../ node_modules / react-native-firebase / ios / RNFirebase'

The result is that extension is created but when I try to share something, nothing happens. 结果是创建了扩展,但是当我尝试共享某些内容时,没有任何反应。 On Debugging the extension with Xcode the log shows the error shown above. 在使用Xcode调试扩展时,日志显示上面显示的错误。

Any idea? 任何想法? Thanks 谢谢

I was able to get this working after following the standard installation instructions, make sure you do the following: 按照标准安装说明操作后,我能够正常工作,请确保执行以下操作:

  1. Link libRNFirebase.a in your Extension's Build Phases. 在Extension的Build阶段中链接libRNFirebase.a Also, make sure that libPods-{YOUR_EXTENSION_NAME}.a is linked as well. 另外,请确保libPods-{YOUR_EXTENSION_NAME}.a也已关联。
  2. Set the GoogleService-Info.plist target for both your main app and your share extension in the right panel. 在右侧面板中为主应用和共享扩展设置GoogleService-Info.plist目标。
  3. In your share extension's Build Settings > Other Linker Flags, make sure you add $(inherited) 在您的共享扩展程序的Build Settings> Other Linker Flags中,确保添加$(继承)
  4. In your Share Extension .m file, make sure you import Firebase and configure it there as well! 在您的Share Extension .m文件中,请确保您导入Firebase并在其中进行配置!

For more info, see the following GitHub thread: https://github.com/alinz/react-native-share-extension/issues/79 有关更多信息,请参阅以下GitHub线程: https//github.com/alinz/react-native-share-extension/issues/79

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM