体系结构 armv7 的未定义符号:“_OBJC_CLASS_$_GGLContext”,引用自:objc-class-ref in AppDelegate.o

Undefined symbols for architecture armv7: "_OBJC_CLASS_$_GGLContext", referenced from: objc-class-ref in AppDelegate.o

我正在尝试在我的 iSO 应用程序中添加 Google Analytics,并且我正在使用 Google Analytics 最新的 SDK https://developers.google.com/analytics/devguides/collection/ios/v3/.

已成功将所有必需的 header 和框架添加到我的项目中。但是当 运行 我的应用程序出现以下错误时

  1. (null):“_OBJC_CLASS_$_GGLContext”,在 AppDelegate.o

    [=30 中引用了 from:objc-class-ref =]
  2. (null):链接器命令失败,退出代码为 1(使用 -v 查看调用)

下面是我在AppDelegate.m文件

中编写的代码
// Configure tracker from GoogleService-Info.plist.
NSError *configureError;
[[GGLContext sharedInstance] configureWithError:&configureError];
NSAssert(!configureError, @"Error configuring Google services: %@", configureError);

// Optional: configure GAI options.
GAI *gai = [GAI sharedInstance];
gai.trackUncaughtExceptions = YES;  // report uncaught exceptions
gai.logger.logLevel = kGAILogLevelVerbose;  // remove before app release

还包括(_OBJC_CLASS_$_GIDSignInButton 和 _OBJC_CLASS_$_GIDSignIn) 请告诉我我缺少什么。提前致谢。

看起来您没有链接其中一个 Google libraries;我猜分析。

尝试将 libGGLCore.a 和 libGGLAnalytics.a 添加到 Link 带有库的二进制文件

如果您像 link 建议的那样使用 pod 安装库,请确保在 运行 pod 安装时检查是否有任何错误。可能是您更改了构建设置中的 OTHER_CFLAGS 或 OTHER_LDFLAGS,这可能会导致问题。 如果是这种情况,您可能想在这两个标志的新行中添加“$(inherited)”。

"The OPN [Debug] target overrides the OTHER_LDFLAGS build setting"。这是主要问题。在其他链接器标志的新行中添加 $(inherited) 后解决了我的问题。

一个小错误,Google SDK 不工作。我是 CocoaPods 的新手,我不知道您必须在目标中添加 google analytics pod。像这样:

# Uncomment this line to define a global platform for your project
platform :ios, '8.0'
# Uncomment this line if you're using Swift
# use_frameworks!   

target 'NAME_OF_THE_TARGET' do
  pod 'Google/Analytics'
end

我在设置开发目标时发生了这种情况。生产目标运行良好,但开发不断出现这些错误。我的问题在 pod 文件中。一开始:

target 'NAME-OF-TARGET' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!

# Pods for MAIN-TARGET
pod 'GoogleSignIn'
pod 'Firebase/Core'
pod 'Firebase/Database'

target 'DEV TARGET' do
    inherit! :search_paths           <----------
    # Pods for dev-target
    pod 'GoogleSignIn'
    pod 'Firebase/Core'
    pod 'Firebase/Database'
end

我用箭头指出的那一行是问题所在。 我将它从 inherit! :search_paths 更改为 use_frameworks! 并且错误已完成。