通过 CocoaPods 使用 Google Analytics 时,“链接器命令失败,退出代码为 1" [英] 'Linker command failed with exit code 1' when using Google Analytics via CocoaPods

查看:23
本文介绍了通过 CocoaPods 使用 Google Analytics 时,“链接器命令失败,退出代码为 1"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将 Google Analytics 添加到用 Swift 编写的 iOS 应用程序中.我遵循了通过 CocoaPods 添加框架的指南并添加了桥接头,但我仍然得到:

I'm trying to add Google Analytics to an iOS app written in Swift. I've followed the guide that adds the frameworks via CocoaPods and added a bridging header but I'm still getting:

Linker command failed with exit code 1

我的 podfile 确实有 use_frameworks!所以我想知道这是否与此有关……我所看到的 Analytics 网站上没有其他信息.

My podfile does have use_frameworks! so I'm wondering if that has anything to do with it... there is no additional information on the Analytics site from what I can see.

我注意到在查看完整的错误消息后会显示以下内容:

I've noticed that after viewing the full error message the following is displayed:

ld: '/Users/simon/Programming/VenueNow/Pods/GoogleUtilities/Libraries/libGTM_NSData+zlib.a(GTMNSData+zlib.o)' does not contain bitcode. 
You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. for architecture arm64

搜索该问题后发现 Google 已更新以支持位代码,但当时尚未更新可可豆荚框架.

And searching for that issue brings up that Google updated to support bit code but hadn't updated the cocoa pods framework at that time.

推荐答案

我遇到了同样的问题.幸运的是,您可以在启用 BitCode 的情况下使用 Google Analytics,但由于 Google 设置其 CocoaPods 支持的方式,这有点令人困惑.

I had this same issue. Fortunately you can use Google Analytics with BitCode enabled, but it's a bit confusing due to how Google had set up their CocoaPods support.

实际上您可以使用 2 个 CocoaPods:

There's actually 2 CocoaPods you can use:

  • 'Google/分析'
  • 'GoogleAnalytics'

第一个是最新的",但它与更大的 Google Pod 相关联,因此不支持 Bitcode.第二个仅用于分析并且支持 BitCode.但是,由于后者不包含额外的 Google pod,因此有关如何设置它的一些说明是不正确的.

The first one is the "latest" but it's tied to the greater Google pods so it does not support Bitcode. The second one is for Analytics only and does support BitCode. However because the latter does not include extra Google pods some of the instructions on how to set it up are incorrect.

您必须使用 v2 方法来设置分析:

You have to use the v2 method of setting up analytics:

// Inside AppDelegate:

// Optional: automatically send uncaught exceptions to Google Analytics.
GAI.sharedInstance().trackUncaughtExceptions = true

// Optional: set Google Analytics dispatch interval to e.g. 20 seconds.
GAI.sharedInstance().dispatchInterval = 20

// Create tracker instance.
let tracker = GAI.sharedInstance().trackerWithTrackingId("XX-XXXXXXXX-Y")

其余的 Google Analytics api 您可以使用 v3 文档(您不需要使用 v2).

The rest of the Google analytics api you can use the v3 documentation (you don't need to use v2).

截至撰写本文时,Google/Analytics"cocoapod 仍不支持 BitCode.见此处

The 'Google/Analytics' cocoapod as of this writing still does not support BitCode. See here

这篇关于通过 CocoaPods 使用 Google Analytics 时,“链接器命令失败,退出代码为 1"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆