Dan*_*e B 7 google-analytics admob ios cocoapods swift
假设:
pod 'Google/Analytics:https:
//developers.google.com/analytics/devguides/collection/ios/v3/? ver = swiftpod 'Google-Mobile-Ads-SDK', '~> 7.0':https:
//developers.google.com/admob/ios/quick-start#streamlined_using_cocoapodsGoogleService-Info.plist使用此处报告的按钮生成了配置文件,同时指定了Analytics和AdMob服务:https://developers.google.com/analytics/devguides/collection/ios/v3/?ver = swift #get-config当我启动应用程序时,我收到警告:
您已在开发者控制台中启用了AdMob服务,但看起来好像您的Podfile缺少"pod"Google/AdMob"或者您可能需要
pod update在项目目录中运行.
然后应用程序崩溃并出现错误:
断言失败:配置Google服务时出错:可选(错误域= com.google.greenhouse代码= -106"缺少预期的子规格."UserInfo = {NSLocalizedFailureReason =某些子规格未安装pod.有关详细信息,请参阅日志.,NSLocalizedDescription =缺少预期subspecs.}):file /myapp/AppDelegate.swift
这个代码由断言行引发,谷歌分析文档说要添加到AppDelegate.swift文件中:
// Configure tracker from GoogleService-Info.plist.
var configureError:NSError?
GGLContext.sharedInstance().configureWithError(&configureError)
assert(configureError == nil, "Error configuring Google services: \(configureError)")
Run Code Online (Sandbox Code Playgroud)
我试着替换
pod 'Google-Mobile-Ads-SDK', '~> 7.0' 同 pod 'Google/AdMob'
该应用程序不再崩溃,但我收到警告:
您目前使用的是SDK 7.6.0版.请考虑将SDK更新为最新的SDK版本,以获取最新功能和错误修复
这是我的完整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
Run Code Online (Sandbox Code Playgroud)
sta*_*hop 18
使用GoogleService-Info.plist文件很容易维护.
只需启用/禁用所需的服务:
如果您选择使用其中一些,则需要在Podfile中指定它们.例如.
pod 'Google/CloudMessaging'
Run Code Online (Sandbox Code Playgroud)
另一种方法是指定您要使用Firebase.只需调制你的Podfile:
pod 'Firebase/Core'
Run Code Online (Sandbox Code Playgroud)
我决定使用Google/AdMob由配置文件支持的pod line GoogleService-Info.plist,因为这似乎是管理多个 Google 服务的最一致的方式。
唯一的问题是它目前的更新周期较慢:AdMob pod 仍为 7.6 版本,而不是最新的 7.7。不过我还是更喜欢这样。无论如何,它应该经常更新。
| 归档时间: |
|
| 查看次数: |
5003 次 |
| 最近记录: |