2015-10-30 51 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,和目標 - 是