在Swift应用中整合Google Analytics [英] Integration Google Analytics in Swift App

查看:142
本文介绍了在Swift应用中整合Google Analytics的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遵循本手册(



请帮助我!

解决方案

几天前,我遇到了类似的问题。您应该遵循以下步骤。




  • 安装Cocoapods

  • 在终端中,导航到具有您的Xcode项目。

  • 输入 pod init
  • c> pod install (我知道这听起来很早,但我会解释)
  • 打开工作区文件并查找由Cocoapods创建的pod文件。编辑该文件以包含 pod'Google / Analytics'

  • 返回终端并键入 pod install 。我可能不会让Cocoapods与我创建的podfile一起工作,所以必须使用他们创建的那个。

  • 现在,安装后,您应该看到已下载项目。 li>
  • 返回工作区文件,并设置您的 -Bridging-Header.h

  • -Bridging-Header.h中输入 #importGoogle / Analytics.h

  • 如果由于某种原因不起作用(它不适用于我),请键入每个单独的项目。

  • 确保为您的项目添加正确的目录-Bridging-Header.h。你可以在Project - Build Settings - Swift Compiler Code Generation下找到它。使用它可以轻松地定位您的头文件$(SWIFT_MODULE_NAME)-Bridging-Header.h

  • .plist 文件拖放到Xcode中,选择所有的目标,如下图所示。



导入到Xcode的导航器中,并看到一个PODS文件夹,里面有一堆Google的东西。它应该在导航器中看起来像这样。



这应该让你摆脱束缚。我遇到了很多与您的问题非常相似的问题。让我知道你是否需要澄清某些事情。


I follow this manual(https://developers.google.com/analytics/devguides/collection/ios/v3/?ver=swift#get-config) to integrate Google analytics in my app. But i getting some error when i try to test it!

ld: framework not found GoogleInterchangeUtilities

I have already made this:

1)in podfile:

pod 'Google/Analytics' -> pod install

2) in 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 already added to my project. But i don't understand what google mean say: "Add GoogleService-Info.plist to each target!!!"

I try add a GoogleInterchangeUtilities framework to "Link Binary With Libraries" and "Copy Frameworks" but it did not help!

Help me please!

解决方案

I ran into a similar problem a couple of days ago. You should follow these steps.

  • Install Cocoapods
  • In Terminal, navigate to the directory which has your Xcode Project in it.
  • Type pod init
  • Then type pod install (I know this sounds early but I will explain)
  • Open the workspace file and find the podfile that was created by Cocoapods. Edit that file to include pod 'Google/Analytics'
  • Go back to terminal and type pod install again. I could get not get Cocoapods to work with the podfile I created, so had to use the one they created.
  • Now, upon install, you should see that items have been downloaded.
  • Go back into the workspace file, and set up your -Bridging-Header.h
  • Type this into the -Bridging-Header.h #import "Google/Analytics.h"
  • If for some reason that doesn't work (it didn't for me), the type each individual item.
  • Be sure to add the correct directory for your -Bridging-Header.h. You can find this under Project - Build Settings - Swift Compiler Code Generation. Use this to easily target your header file $(SWIFT_MODULE_NAME)-Bridging-Header.h
  • Drag the .plist file into Xcode and select all of the targets, as seen in the below picture.

You will know that everything has installed correctly when you look into the Navigator in Xcode and see a PODS folder with a bunch of Google stuff in it. It should look like this in the navigator.

That should have you squared away. I ran into many issues very similar to yours. Let me know if you need clarification on something.

这篇关于在Swift应用中整合Google Analytics的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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