Swift 使用未声明的类型 'GGLInstanceIDDelegate'

Swift Use of undeclared type 'GGLInstanceIDDelegate'

我正在尝试在我的 iOS 应用程序中实施 Google 云消息传递。 但我一直收到错误

Use of undeclared type 'GGLInstanceIDDelegate'

我一直在按照 Google 支持页面上的说明进行操作,但无济于事。我的代码如下所示:

import UIKit

@UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate, GGLInstanceIDDelegate {

    var window: UIWindow?

    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        // Override point for customization after application launch.
        var osV = String(getMajorSystemVersion())

        if osV == "7"
        {
            UIApplication.sharedApplication().registerForRemoteNotificationTypes(UIRemoteNotificationType.Badge | UIRemoteNotificationType.Sound | UIRemoteNotificationType.Alert)
        }
        else if osV == "8"
        {
            // Register for remote notifications
            var types: UIUserNotificationType = UIUserNotificationType.Badge | UIUserNotificationType.Alert | UIUserNotificationType.Sound
            var settings: UIUserNotificationSettings = UIUserNotificationSettings( forTypes: types, categories: nil )
            application.registerUserNotificationSettings( settings )
            application.registerForRemoteNotifications()
        }

/* All the line below are throwing a similar error */  //GGLInstanceID.sharedInstance().startWithConfig(GGLInstanceIDConfig.defaultConfig())
//registrationOptions = [kGGLInstanceIDRegisterAPNSOption:deviceToken, kGGLInstanceIDAPNSServerTypeSandboxOption:true]
//GGLInstanceID.sharedInstance().tokenWithAuthorizedEntity(gcmSenderID, scope: kGGLInstanceIDScopeGCM, options: registrationOptions, handler: registrationHandler)

        return true
    }

我正在进入我的 class 声明:

@UIApplicationMain 
class AppDelegate: UIResponder, UIApplicationDelegate, GGLInstanceIDDelegate {

有人成功过吗?我将不胜感激任何帮助。我认为这与链接或类似的东西有关。

您必须在 "Swift Compiler Generation" -> "Objective-C Bridging Header" 下的 Xcode 构建设置中设置桥接头,如下所示:

"$(SRCROOT)/$(PROJECT_NAME)/ObjCBridgingHeader.h"