LoginSignup
1
2

More than 5 years have passed since last update.

Xcode8でFirebaseのCrashReportingが動かなかった時の解決法

Posted at

Xcode8でFirebaseのCrash Reportingを使おうとしたらハマったのでその時の話をメモっときます。

環境

Xcode 8.1
CocoaPods 1.1.0
Firebase 3.9.0
FirebaseAnalytics 3.5.1
FirebaseCore 3.4.4
FirebaseCrash 1.1.3

(1) Firebaseの導入

まずは、https://firebase.google.com/docs/ios/setup に書いてある通りにFirebaseを導入していきます。

その後、iOSシミュレータ上で動かしてみると、以下のようなエラーが出ました。

<FIRInstanceID/WARNING> STOP!! Will reset deviceID from memory.
<FIRInstanceID/WARNING> Failed to fetch default token Error Domain=com.firebase.iid Code=6 “(null)”

20161121133109.png

明らかにうまくいってないです><><どうやらこれKeyChain周りのせいで発生するっぽい?
というのも、Xcode8のシミュレータからはKeyChainにアクセスできないというバグがあるらしいのです。。><

これに対処するために、 CaoabukutuesのKeychain sharingをONにします。

20161121133942.png

これで自分は入りました。

(2) Crash Repotingの導入

次に、Crash Reportingを導入します。
これも、先と同様に [https://firebase.google.com/docs/crash/ios] を眺めながら勧めていきます。

そして、最後のスクリプトの追加をする部分、ドキュメントには以下のように書いています。

# Replace this path with the path to the key you just downloaded
JSON_FILE=Path/To/ServiceAccount.json

# Replace this with the GOOGLE_APP_ID from your GoogleService-Info.plist file
GOOGLE_APP_ID=1:my:app:id

defaults write com.google.SymbolUpload version -integer 1   # creates file if it does not exist
JSON=$(cat "${JSON_FILE}")
/usr/bin/plutil -replace "app_${GOOGLE_APP_ID//:/_}" -json "${JSON}" "$HOME/Library/Preferences/com.google.SymbolUpload.plist"
"${PODS_ROOT}"/FirebaseCrash/upload-sym

・・・しかし、これで実行すると下記のようなエラーが発生し、クラッシュ情報を送信することができません><

20161121144200.png

そこで、スクリプトを以下のように書き換えます。

# Replace this path with the path to the key you just downloaded
JSON_FILE=Path/To/ServiceAccount.json

# Replace this with the GOOGLE_APP_ID from your GoogleService-Info.plist file
GOOGLE_APP_ID=1:my:app:id

defaults write com.google.SymbolUpload version -integer 1

JSON=$(cat "${JSON_FILE}")
/usr/bin/plutil -replace "app_${GOOGLE_APP_ID//:/_}" -json "${JSON}" "$HOME/Library/Preferences/com.google.SymbolUpload.plist"
"${PODS_ROOT}"/FirebaseCrash/upload-sym "${JSON_FILE}"

これで自分は動きました。

実際にassert(false)を実行しクラッシュさせた後、この行を消して再起動すると・・
20161121144703.png
クラッシュ情報が送信できました!
20分程度経つと、無事ダッシュボードにも反映されました。よかった。

参考

http://stackoverflow.com/questions/39210860/firebase-upload-symbol-files-build-error-unexpected-argument-serviceaccount-js
https://googledevjp.blogspot.jp/2016/09/ios-10-xcode-8-and-swift-3.html
http://dev.classmethod.jp/smartphone/ios-10-keychain-problem/

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2