假设:
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服务时出错:可选(错误Domain = com.google.greenhouse代码= -106“缺少期望的子规格。” UserInfo = {NSLocalizedFailureReason =未安装某些子规格。有关详细信息,请参阅日志。,NSLocalizedDescription =期望的缺失subspecs。}):文件/myapp/AppDelegate.swift
该代码的断言行抛出了该代码,Google Analytics(分析)文档说要添加到该AppDelegate.swift
文件中:
// Configure tracker from GoogleService-Info.plist.
var configureError:NSError?
GGLContext.sharedInstance().configureWithError(&configureError)
assert(configureError == nil, "Error configuring Google services: \(configureError)")
我试图更换
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
我决定将Pod行与配置文件Google/AdMob
支持一起使用GoogleService-Info.plist
,因为这似乎是管理多个Google服务的最一致的方法。
唯一的问题是,它目前的更新周期较慢:AdMob广告连播的版本仍为7.6,而不是最新的7.7。但是我还是更喜欢这种方式。无论如何,它应该经常更新。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句