xcode - 在 Swift 应用程序中集成 Google Analytics

标签 xcode swift google-analytics

我按照本手册 ( https://developers.google.com/analytics/devguides/collection/ios/v3/?ver=swift#get-config ) 将 Google 分析集成到我的应用程序中。但是当我尝试测试它时出现了一些错误!

ld: framework not found GoogleInterchangeUtilities

我已经做了这个:

1)在播客文件中:

pod 'Google/Analytics' -> pod install

2) 在 APP-Bridging-Header.h 中:

#import "Google/Analytics.h"
#import "GAI.h"
#import "GAIDictionaryBuilder.h"
#import "GAIEcommerceFields.h"
#import "GAIEcommerceProduct.h"
#import "GAIEcommerceProductAction.h"
#import "GAIEcommercePromotion.h"
#import "GAIFields.h"
#import "GAILogger.h"
#import "GAITrackedViewController.h"
#import "GAITracker.h"

3) GoogleService-Info.plist 已经添加到我的项目中。但我不明白谷歌的意思是说:“将 GoogleService-Info.plist 添加到每个目标!!!”

我尝试将 GoogleInterchangeUtilities 框架添加到“Link Binary With Libraries”和“Copy Frameworks”,但它没有帮助!

enter image description here

请帮帮我!

最佳答案

几天前我遇到了类似的问题。您应该按照这些步骤操作。

  • 安装 Cocoapods
  • 在终端中,导航到包含您的 Xcode 项目的目录。
  • 输入pod init
  • 然后输入pod install(我知道这听起来很早,但我会解释)
  • 打开工作区文件并找到 Cocoapods 创建的 podfile。编辑该文件以包含 pod 'Google/Analytics'
  • 返回终端并再次输入 pod install。我无法让 Cocoapods 使用我创建的 podfile,所以不得不使用他们创建的文件。
  • 现在,安装完成后,您应该会看到项目已下载。
  • 返回到工作区文件,并设置您的-Bridging-Header.h
  • 将其输入 -Bridging-Header.h #import "Google/Analytics.h"
  • 如果由于某种原因不起作用(对我来说不起作用),请键入每个单独的项目。
  • 请务必为您的 -Bridging-Header.h 添加正确的目录。您可以在项目 - build设置 - Swift 编译器代码生成下找到它。使用它可以轻松定位您的头文件 $(SWIFT_MODULE_NAME)-Bridging-Header.h
  • .plist 文件拖到Xcode 中并选择所有目标,如下图所示。 enter image description here

当您在 Xcode 中查看 Navigator 并看到一个 PODS 文件夹,里面有一堆 Google 东西时,您就会知道一切都已正确安装。它在导航器中应该看起来像这样。 enter image description here

那应该让你摆平了。我遇到了很多与你非常相似的问题。如果您需要澄清某些事情,请告诉我。

关于xcode - 在 Swift 应用程序中集成 Google Analytics,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37306621/

相关文章:

ios - 共享 .xcarchive 安全吗?

ios - iOS 14 中的 UISplitViewController 在横向模式下按预期工作,但在纵向模式下不正常

javascript - Google Analytics 嵌入 API 错误 : uncaught exception [object Object]

javascript - 谷歌分析如何知道屏幕分辨率?

android - Google Analytics(分析)在Android上无法运作

ios - Segue 总是加载新的 View 实例

ios - 是否可以以编程方式启用 airplay 镜像?

iphone - OpenCV cv::dft()iOS断言错误

Swift SearchBar 无法过滤数据

ios - 如何在 swift 3 中检查变量值?