Adding Google Analytics to your CocoaPod
Intro:
You can add other Pods to your Pod as a dependency defined in your .PODSPEC
file:
Pod::Spec.new do |s|
s.dependency = 'PodName'
end
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 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:
Pod/Classes/Libraries/Analytics
Then I updated my .PODSPEC
file:
Pod::Spec.new 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'
end
After this, pod lib lint
is finally not throwing any warning or errors at me.