“Google/Analytics.h file not found” after updating pod to GoogleAnalytics

别来无恙 提交于 2021-02-08 01:56:38

问题


I was using the pod s

pod 'Google/Analytics'
pod 'Google/SignIn'

but after running pod install I was receiving the following warning at the end of the pod installation

[!] Google has been deprecated

I searched in Google and I found that it is suggested to use the new pods

pod 'GoogleAnalytics'
pod 'GoogleSignIn'

That removes the pod install warning. But makes my build fail with the following error in any file with the line:

#import <Google/Analytics.h>                    (!error)Google/Analytics.h file not found

How can I solve this?


回答1:


The GoogleAnalytics pod changed a few things as how the Google/Analytics pod worked. the Most important change is that GoogleAnalytics does not use the GoogleServices-Info.plist instead you should set up the tracker manually. Also the Google/Analytics.h file no longer exist, you must import the correct file, I leave you some examples.

#import <GoogleAnalytics/GAI.h>
#import <GoogleAnalytics/GAIFields.h>
#import <GoogleAnalytics/GAILogger.h>
#import <GoogleAnalytics/GAIDictionaryBuilder.h>
#import <GoogleAnalytics/GAITrackedViewController.h>
#import <GoogleAnalytics/GAITracker.h>

For more information check the dev guide https://developers.google.com/analytics/devguides/collection/ios/v3/?ver=swift




回答2:


Try delete this files (it will not break your project):

Pods 
*.xcworkspace
podfile.lock

and run pod install

If it does not help you please share your podfile.



来源:https://stackoverflow.com/questions/46847411/google-analytics-h-file-not-found-after-updating-pod-to-googleanalytics

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!