2015-10-30 50 views
2

我需要在我的应用中使用GoogleCloudMessaging。我通过Cocoapods安装它。 当我加入这部分代码:GoogleCloudMessaging关联错误

GLInstanceIDConfig *instanceIDConfig = [GGLInstanceIDConfig defaultConfig]; 
    instanceIDConfig.delegate = self; 
    // Start the GGLInstanceID shared instance with the that config and request a registration 
    // token to enable reception of notifications 
    [[GGLInstanceID sharedInstance] startWithConfig:instanceIDConfig]; 
    _registrationOptions = @{kGGLInstanceIDRegisterAPNSOption:deviceToken, 
          kGGLInstanceIDAPNSServerTypeSandboxOption:@YES}; 
    [[GGLInstanceID sharedInstance] tokenWithAuthorizedEntity:GCMSSenderID 
                 scope:kGGLInstanceIDScopeGCM 
                 options:_registrationOptions 
                 handler:_registrationHandler]; 

而且我有这些错误:

Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_GGLInstanceID", referenced from: objc-class-ref in AppDelegate.o "_OBJC_CLASS_$_GGLInstanceIDConfig", referenced from: objc-class-ref in AppDelegate.o "_kGGLInstanceIDAPNSServerTypeSandboxOption", referenced from: -[AppDelegate application:didRegisterForRemoteNotificationsWithDeviceToken:] in AppDelegate.o "_kGGLInstanceIDRegisterAPNSOption", referenced from: -[AppDelegate application:didRegisterForRemoteNotificationsWithDeviceToken:] in AppDelegate.o "_kGGLInstanceIDScopeGCM", referenced from: -[AppDelegate application:didRegisterForRemoteNotificationsWithDeviceToken:] in AppDelegate.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

项目设置:

- >构建有源体系只有 - YES

- >其他链接标记包含$(继承)

- >部署t arget - 8.0

请帮帮我! 在此先感谢!

+0

确保你正在构建的工作空间,而不是项目,因为的CocoaPods是在工作区中的另一个单独的项目 – user102008

回答

0

此错误是因为您的项目中缺少一些库。

检查您的Build Phases -> Link Binary With Libraries。你的任何框架可能已经从那里删除。

添加它并清理并构建您的项目。

可能会帮助你。

1

检查4两件事:

  1. 您没有手动上传项目中的Google云端通讯。如果有,请删除它们并重新安装豆荚。

  2. 检查您的链接器构建设置中的路径设置。在安装pod之前,使用'$继承'。

  3. 重新安装吊舱后,随着CMD + 转变 + ķ和运行项目清理项目。

  4. 构建有源体系只有 - NO,和目标 - 是