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.

12
  • make sure you add a bridge header in SWIFT Commented Aug 3, 2015 at 9:36
  • @ Daniel under Supporting Files I have added BridgingHeader.h with content: #import <Google/CloudMessaging.h> Exactly like the google demo project
    – Nebula
    Commented Aug 3, 2015 at 9:37
  • great, try to clear derived data window->projects->delete (on derived data) Commented Aug 3, 2015 at 9:39
  • @Daniel Nope still same error, tried cleaning the project also..
    – Nebula
    Commented Aug 3, 2015 at 9:43
  • my podfile looks like this: pod 'Google/CloudMessaging' target 'Notifications' do end target 'HelloSwiftTests' do end
    – Nebula
    Commented Aug 3, 2015 at 9:45

1 Answer 1

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"
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.