错误:使用未解析的标识符' FIRApp'

时间:2017-03-03 22:13:06

标签: swift xcode firebase xcode8 firebase-cloud-messaging

我一直收到错误使用未解析的标识符' FIRApp'。我删除了我的派生数据文件夹,更新了pod,并多次重新安装了pod。我目前正在使用xcode 8.2.1。我的pod版本是 使用Firebase(3.14.0) 使用FirebaseAnalytics(3.7.0) 使用FirebaseCore(3.5.1) 使用FirebaseInstanceID(1.0.9) 使用FirebaseMessaging(1.2.2) 使用GoogleToolboxForMac(2.1.1) 使用Protobuf(3.2.0)。我正在使用最新版本的cocoapods。谢谢你的帮助。

import UIKit
    import UserNotifications
    import Firebase
    import FirebaseInstanceID
    import FirebaseMessaging

    @UIApplicationMain
    class AppDelegate: UIResponder, UIApplicationDelegate {

        var window: UIWindow?
        let gcmMessageIDKey = "gcm.message_id"

        func application(_ application: UIApplication,
                         didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

            // Register for remote notifications. This shows a permission dialog on first run, to
            // show the dialog at a more appropriate time move this registration accordingly.
            // [START register_for_notifications]
            if #available(iOS 10.0, *) {
                // For iOS 10 display notification (sent via APNS)
                UNUserNotificationCenter.current().delegate = self

                let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound]
                UNUserNotificationCenter.current().requestAuthorization(
                    options: authOptions,
                    completionHandler: {_, _ in })

                // For iOS 10 data message (sent via FCM)
                FIRMessaging.messaging().remoteMessageDelegate = self

            } else {
                let settings: UIUserNotificationSettings =
                    UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil)
                application.registerUserNotificationSettings(settings)
            }

            application.registerForRemoteNotifications()

            // [END register_for_notifications]
            FIRApp.configure()

            // [START add_token_refresh_observer]
            // Add observer for InstanceID token refresh callback.
            NotificationCenter.default.addObserver(self,
                                                   selector: #selector(self.tokenRefreshNotification),
                                                   name: .firInstanceIDTokenRefresh,
                                                   object: nil)
            // [END add_token_refresh_observer]
            return true
        }

1 个答案:

答案 0 :(得分:2)

我遇到了同样的问题并解决了它在命令行上执行以下步骤:

  1. pod repo update
  2. 从我的Podfile
  3. 中注释了pod'Firebase'行
  4. pod install(这删除了旧的Firebase)
  5. 再次添加了“Firebase”广告连播。
  6. pod install(添加了新的Firebase)