Error installing google analytics on iOS app

橙三吉。 提交于 2019-12-22 13:30:10

问题


I was trying to integrate google analytics into my project, and I was surprised that it requires cocoapods to install google analytics now.

I followed the documentation here:

https://developers.google.com/analytics/devguides/collection/ios/v3/?hl=en

I called pod init on terminal, and then I've edited by podfile to

# Uncomment this line to define a global platform for your project
# platform :ios, '6.0'

target 'Unity-iPhone' do
pod 'Google/Analytics', '~> 1.0.0'
end

target 'Unity-iPhone Tests' do

end

and I get the following error on terminal when I call pod install.

Updating local specs repositories Analyzing dependencies [!] Unable to find a specification for Google/Analytics (~> 1.0.0)

[!] CocoaPods was not able to update the master repo. If this is an unexpected issue and persists you can inspect it running pod repo update --verbose

It also did not generate the .xcworkspace file.

How can I fix this issue?

Edit:

I tried the answer by Steffen to setup the master repo again, and I get this error now.

Analyzing dependencies [!] Unable to satisfy the following requirements:

  • Google/Analytics (~> 1.0.0) required by Podfile

Although my podfile still contains pod 'Google/Analytics', '~> 1.0.0'


回答1:


I had this problem on OS X El Capitan Version 10.11.5

  1. Open terminal command prompt
  2. Path to your XCode project folder

    $ cd /path/to/xcode/myProject/
    
  3. Create the Podfile using command

    $ pod init
    
  4. Add the line pod 'Google/Analytics' to the generated Podfile
     # Uncomment this line to define a global platform for your project
     # platform :ios, '8.0'
     # Uncomment this line if you're using Swift
     # use_frameworks!

     target 'myProject' do 
     pod 'Google/Analytics'
     end
  1. Try to install the pod which fails

    $ pod install
    -bash: pod: command not found
    
  2. Try to install cocoapods which also fails

    $ sudo gem install cocoapods 
    ERROR:  Error installing cocoapods: activesupport requires Ruby version >= 2.2.2.
    
  3. You need to install activesupport which then lets you install cocoapods okay but then the pod install fails with a new bug

    $ sudo gem install activesupport -v 4.2.6
    $ sudo gem install cocoapods
    $ pod install
    [!] Unable to find a specification for 'Google/Analytics'
    
  4. Perform these last steps and the pod install will finally succeed

    $ pod repo remove master
    $ pod setup
    $ pod install
    

NB Some of these command line actions take a long time to complete and Terminal gives you no indication that it is doing anything, it appears broken but is working quietly therefore needs patience.

So sad that we still have to resort command line in 2016




回答2:


Sounds like your master repo is somehow corrupt. I would try the following:

pod repo remove master
pod setup



回答3:


Setting the project deployment target to 7.0 fixed the issue.



来源:https://stackoverflow.com/questions/32871329/error-installing-google-analytics-on-ios-app

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