Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS: CocoaPods issue with Google Analytics and AdMob

Assuming:

  • I have configured CocoaPods for Google Analytics, using pod 'Google/Analytics, following the official installation guide: https://developers.google.com/analytics/devguides/collection/ios/v3/?ver=swift
  • I have configured CocoaPods for AdMob, using pod 'Google-Mobile-Ads-SDK', '~> 7.0', following the official installation guide: https://developers.google.com/admob/ios/quick-start#streamlined_using_cocoapods
  • I generated the GoogleService-Info.plist configuration file, specifying both Analytics and AdMob services, using the button reported here: https://developers.google.com/analytics/devguides/collection/ios/v3/?ver=swift#get-config

When I start the app I get the warning:

You have enabled the AdMob service in Developer Console, but it appears as though your Podfile is missing the line: 'pod "Google/AdMob" or you may need to run pod update in your project directory.

Then the app crashes with the error:

assertion failed: Error configuring Google services: Optional(Error Domain=com.google.greenhouse Code=-106 "Missing expected subspecs." UserInfo={NSLocalizedFailureReason=Some subspecs are not pod installed. See log for details., NSLocalizedDescription=Missing expected subspecs.}): file /myapp/AppDelegate.swift

which is thrown by the assert line, of this code the Google Analytics documentation said to add in the AppDelegate.swift file:

// Configure tracker from GoogleService-Info.plist.
var configureError:NSError?
GGLContext.sharedInstance().configureWithError(&configureError)
assert(configureError == nil, "Error configuring Google services: \(configureError)")



I tried to I replace

pod 'Google-Mobile-Ads-SDK', '~> 7.0' with pod 'Google/AdMob'

The app doesn't crash anymore, but I get the warning:

You are currently using version 7.6.0 of the SDK. Please consider updating your SDK to the most recent SDK version to get the latest features and bug fixes


This is my full Podfile:

source 'https://github.com/CocoaPods/Specs.git'

platform :ios, '8.0'
use_frameworks!  # needed when using Swift


target 'myProject' do

    pod 'Google/Analytics'
    pod 'GoogleIDFASupport'
    pod 'Google-Mobile-Ads-SDK', '~> 7.0'

    pod 'Fabric'
    pod 'Crashlytics'

    pod 'SQLite.swift', '~> 0.9.2'    

end
like image 343
Daniele B Avatar asked Mar 15 '16 00:03

Daniele B


4 Answers

Its easy to maintain using GoogleService-Info.plist file.

Just enable/disable services you want:

enter image description here

If you choosed you want to use some of them, then you need to specify them in your Podfile. Eg.

pod 'Google/CloudMessaging'

Full list of Google SDKs is available here.

Another way is to specify that you want to use Firebase. Just modufy your Podfile:

pod 'Firebase/Core'
like image 177
stakahop Avatar answered Nov 19 '22 09:11

stakahop


Have you tried to edit GoogleService-Info.plist and change "IS_ADS_ENABLED" to "NO"? If you are using "Google-Mobile-Ads-SDK" instead of "Google/AdMob" then your Ads should still work. "GoogleService-Info.plist" is not a requisite for AdMob (https://developers.google.com/admob/ios/quick-start#prerequisites).

like image 3
fabio914 Avatar answered Nov 19 '22 08:11

fabio914


I had the same issue

Change

pod 'Google-Mobile-Ads-SDK', '~> 7.0'

to

pod 'Google/AdMob'

Only problem is pod 'Google/AdMob' is one release behind (7.6)

like image 1
Tibidabo Avatar answered Nov 19 '22 07:11

Tibidabo


I decided to use the pod line with Google/AdMob, supported by the GoogleService-Info.plist configuration file, as it seems the most consistent way to manage multiple Google services.

The only problem is that it currently has a slower update cycle: the AdMob pod there is still at version 7.6 instead of the latest 7.7. However I still prefer that way. It should get updated pretty often anyway.

like image 1
Daniele B Avatar answered Nov 19 '22 07:11

Daniele B