Google 跟踪代码管理器实施

Google Tag Manager Implementation

我正在为我的 iOS 应用程序集成 Google 标签管理器。我下载了所有需要的文件,它们是:TAGManager.hTAGContainer.hTAGContainerOpener.hTAGDataLayer.hTAGLogger.h

当我在我的项目中添加这些时,代码可以编译,但是当它开始链接时会抛出如下错误:

Undefined symbols for architecture arm64:
"OBJC_CLASS$_TAGContainerOpener", referenced from:
objc-class-ref in AppDelegate.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

我在 AppDelegate.swift 文件中添加了以下代码:

TAGContainerOpener.openContainer(withId: "GTM-PT3L9Z",
tagManager: GTM, openType: kTAGOpenTypePreferFresh,
timeout: nil,
notifier: self)

谁能告诉我为什么会出现此链接错误。

我相信您可能正在使用旧的实现。最新版本是 v5 (Firebase + GTM),这里是 docs