【Swift3】【cocoapods】【googleアナリティクス】その1

googleが提供するAnalyticsには、「Firebase Analytics」と「Google アナリティクス」があるらしい。
下記サイトによると、Firebase Analyticsはアプリのみ、Google アナリティクスはWebページとアプリ、って使い分けるらしい。
今すでにWebページもアプリもGoogle アナリティクスでやってるので引き続きGoogle アナリティクスでやってみる。

参考サイト
Firebase Analytics を iOS / Android アプリに導入する手順のまとめ | Developers.IO

Firebase Analytics
iOS アプリにアナリティクスを追加する  |  iOS 向けアナリティクス  |  Google Developers

以前にもgoogleアナリティクスを導入する記事を書いたが、
【cocoapods】でGoogleAnalyticsを導入 その1 | iPhoneアプリ備忘録
改めて書いてみる。

まずは昔の記事
超初心者向け【cocoapods】の始め方。 | iPhoneアプリ備忘録
を見直して

$ pod setup

ターミナルを最新版に?してみる。
ながーいログのあと、

Checking out files: 100% (4782/4782), done.

CocoaPods 1.2.0.beta.1 is available.
To update use: `gem install cocoapods --pre`
[!] This is a test version we'd love you to try.

For more information see http://blog.cocoapods.org
and the CHANGELOG for this version http://git.io/BaH8pQ.

Setup completed

と表示されてcocoaPodsが無事にアップデートされたようだ。

次いで、ターミナルをアプリの有るディレクトリに移動してから、

$ pod init

ポッドファイルを作成し、中身を下記のように書き換えて、

# Uncomment this line to define a global platform for your project
platform :ios, ’10.0’
# Uncomment this line if you're using Swift
# use_frameworks!

target 'FirstSwift' do
pod 'Google/Analytics'
end

target 'FirstSwiftTests' do

end

target 'FirstSwiftUITests' do

end

ターミナルから実行↓

$ pod install
Updating local specs repositories

CocoaPods 1.2.0.beta.1 is available.
To update use: `gem install cocoapods --pre`
[!] This is a test version we'd love you to try.

For more information see http://blog.cocoapods.org
and the CHANGELOG for this version http://git.io/BaH8pQ.

Analyzing dependencies
Downloading dependencies
Installing FirebaseAnalytics (3.5.1)
Installing FirebaseCore (3.4.4)
Installing FirebaseInstanceID (1.0.8)
Installing Google (3.0.3)
Installing GoogleAnalytics (3.17.0)
Installing GoogleInterchangeUtilities (1.2.2)
Installing GoogleSymbolUtilities (1.1.2)
Installing GoogleToolboxForMac (2.1.0)
Generating Pods project
Integrating client project

[!] Please close any current Xcode sessions and use `FirstSwift.xcworkspace` for this project from now on.
Sending stats
Pod installation complete! There is 1 dependency from the Podfile and 8 total
pods installed.

[!] Your Podfile has had smart quotes sanitised. To avoid issues in the future, you should not use TextEdit for editing it. If you are not using TextEdit, you should turn off smart quotes in your editor of choice.
appleharikyu:FirstSwift ____$ 

インストール完了。

インストール後、開くのは「プロジェクト名.xcodeproj」ではなく「プロジェクト名.xcworkspace」のようだ。
気をつけないとね。

次は設定に続く。

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です