OStack程序员社区-中国程序员成长平台

标题: ios - GoogleCloudMessaging 链接错误 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-13 11:38
标题: ios - GoogleCloudMessaging 链接错误

我需要在我的应用中使用 GoogleCloudMessaging。我通过 Cocoapods 安装了它。 当我添加这部分代码时:

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,
                             kGGLInstanceIDAPNSServerTypeSandboxOptionYES};
    [[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)

项目设置:

-> 仅构建事件架构 - 是

-> 其他链接标志包含 $(inherited)

-> 部署目标 - 8.0

请帮帮我! 提前致谢!



Best Answer-推荐答案


检查 4 件事:

  1. 您尚未在项目中手动上传 GoogleCloudMessaging。如果有,请删除它们并重新安装 pod。

  2. 检查您的build设置中的链接器路径设置。在安装 pod 之前使用 '$inherited'。

  3. 重新安装 pod 后,使用 cmd + shift + k 清理您的项目,然后运行您的项目。

  4. 仅构建事件架构 - 否,针对目标 - 是

关于ios - GoogleCloudMessaging 链接错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33430435/






欢迎光临 OStack程序员社区-中国程序员成长平台 (https://ostack.cn/) Powered by Discuz! X3.4