1

I am trying to implement Google Cloud Messaging into my iOS app. But I keep getting the error

Use of undeclared type 'GGLInstanceIDDelegate'

I have been following the instructions on Google's support pages but to no avail. My code looks like:

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
    }

I am getting in my class declaration:

@UIApplicationMain 
class AppDelegate: UIResponder, UIApplicationDelegate, GGLInstanceIDDelegate {

Has anybody had success with this? I would appreciate any help. I think it has to do with the linking or something like that.

Dharmesh Kheni
  • 71,228
  • 33
  • 160
  • 165
Nebula
  • 679
  • 2
  • 17
  • 37

1 Answers1

4

You have to set the Bridging Header in the Xcode Build Settings under "Swift Compiler Generation" -> "Objective-C Bridging Header" like this:

"$(SRCROOT)/$(PROJECT_NAME)/ObjCBridgingHeader.h"
Darko
  • 9,655
  • 9
  • 36
  • 48