Adding Google Analytics to your CocoaPod


You can add other Pods to your Pod as a dependency defined in your .PODSPEC file: do |s|

  s.dependency = 'PodName'


Then all you need to do is run pod install.

Adding Google Analytics

But if you try to add 'Google/Analytics' as dependency, you are :poop: out of luck. ( At least I was, as I could not find any other way to add it. )

It’s great that Google is using Cocoapods to distribute their SDK, but it is still the same crappy Obj-C Static library.

So, to avoid conflicts with frameworks and static libraries I decided to download Analytics SDK and add all files (.h headers and .a libraries) to my Pod in path:


Then I updated my .PODSPEC file: do |s|

  s.source_files = 'Pod/Classes/**/*'
  s.libraries = 'sqlite3', 'c++', 'icucore', 'z'
  s.frameworks = 'CoreData', 'Foundation', 'SystemConfiguration'
  s.vendored_libraries  = 'Pod/Classes/Libraries/Analytics/libGoogleAnalyticsServices.a', 'Pod/Classes/Libraries/Analytics/libAdIdAccess.a'


After this, pod lib lint is finally not throwing any warning or errors at me.

Martin Púčik

Martin Púčik

Swift Developer

comments powered by Disqus
rss facebook twitter github youtube mail spotify lastfm instagram linkedin google google-plus pinterest medium vimeo stackoverflow reddit quora quora