Быстрое использование необъявленного типа 'GGLInstanceIDDelegate'

Я пытаюсь внедрить Google Cloud Messaging в мое приложение для iOS. Но я продолжаю получать ошибку

Использование необъявленного типа '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
    }

Я получаю в своем объявлении класса:

@UIApplicationMain 
class AppDelegate: UIResponder, UIApplicationDelegate, GGLInstanceIDDelegate {

Кто-нибудь имел успех с этим? Буду признателен за любую помощь. Я думаю, что это связано со ссылками или что-то в этом роде.

1 ответ

Решение

Вы должны установить Bridging Header в Настройках сборки XCode в "Генерации компилятора Swift" -> "Objective-C Bridging Header" как это:

"$(SRCROOT)/$(PROJECT_NAME)/ObjCBridgingHeader.h"
Другие вопросы по тегам