【问题标题】:How to import Firebase inside Xcode如何在 Xcode 中导入 Firebase
【发布时间】:2019-08-22 11:33:01
【问题描述】:

我一直在尝试将 firebase 添加到我的颤振应用程序中,但在此之前,我必须先去 Xcode 并添加一些东西,以便我能够为 iOS 挂钩 firebase。我已经尝试过 import 语句,但没有奏效。此代码在 Dart 代码中。

#include "AppDelegate.h"
#include "GeneratedPluginRegistrant.h"

import Firebase;

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application
    didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  [GeneratedPluginRegistrant registerWithRegistry:self];
  // Override point for customization after application launch.
  return [super application:application didFinishLaunchingWithOptions:launchOptions];
}
override init() {
    FIRApp.configure()
    FIRDatabase.database().persistenceEnabled = true
}

@end

This what I added and did not work and also the import did not work

override init() {
    FIRApp.configure()
    FIRDatabase.database().persistenceEnabled = true
}

【问题讨论】:

标签: ios bash macos flutter xcode10


【解决方案1】:

假设你使用 CocoaPod 作为依赖管理器。

  1. 可选(如果尚未使用 cocoapods)

    pod 初始化

  2. 将 firebase 添加到 podfile 并运行 pod install。

    pod 'Firebase/Core'

  3. 打开工作区而不是项目。并尝试导入框架。

现在应该可以工作了。

Firebase official documentation

【讨论】:

    【解决方案2】:

    您唯一应该做的就是将firebase plist 文件GoogleService-Info.plist 放入ios/Runner 文件夹中。将 firebase 依赖项添加到您的 pubspec.yaml 文件中,然后运行 ​​flutter packages get 这将安装依赖项并为您运行 pod install。如果您过去在 IOS 中使用过 Firebase,并且您没有更新它,那么使用 pod update Firebase 更新它的 pod 版本可能会很好

    请记住,在此之后请完全重启您的应用。

    还请务必在此处阅读此信息https://firebase.google.com/docs/flutter/setup

    【讨论】:

      猜你喜欢
      • 2018-08-10
      • 2017-12-13
      • 2020-10-02
      • 1970-01-01
      • 2017-02-10
      • 1970-01-01
      • 1970-01-01
      • 2011-05-11
      • 1970-01-01
      相关资源
      最近更新 更多