LoginSignup
8
4

More than 1 year has passed since last update.

iOSクラッシュログ(.ipsファイル)のシンボル化チュートリアル

Last updated at Posted at 2021-07-12

環境

  • Xcode 12.5.1
  • iOS 14.6
  • iPhone 8

事前準備

  • ipsファイルを取得するための実機を用意
  • エラー発生用testアプリを作成
    • 今回は画面にUIButtonを配置し、押すとfatalError()を実行するようにした
ViewController.swift
import UIKit

class ViewController: UIViewController {
    @IBAction func didTapErrorButton(_ sender: UIButton) {
        fatalError("an error occurs")
    }
}
  • testアプリをアーカイブ、AdHoc配信のipaを作成し、実機にインストール

手順

1. testアプリでエラーを発生させる

2. 設定アプリ>プライバシー>解析および改善>解析データから対象のipsファイルを取得

  • ips一覧の画面を上にスライドすると検索ボックスが出てくるので、testアプリのプロジェクト名を入力すると対象のipsを見つけやすい
    • 対象ipsのテーブルセルを選択し、右上に共有アイコンからAirDropなどでipsファイルを取得できる

3. XcodeのアプリケーションメニューWindow>Organizerから対象のアーカイブを右クリック。 Show in finderxcarchiveファイルを確認する

4. 対象のxcariveファイルを右クリック、パッケージの内容を表示を選択する

5. 以下のファイルを取得

  • dSYMsフォルダのdSYMファイル
    • シンボル化対象のipsファイルと同一のビルドUUIDを持つdSYMファイルを取得する必要がある。ipsファイル内に記載されたslice_uuidの値と以下のコマンドから出力したdSYMファイルのUUIDが一致することを確認する。
xcrun dwarfdump --uuid {対象のdSYMファイル}/Contents/Resources/DWARF/{testアプリのproject名}
  • BCSymbolMapsフォルダのbcsymbolmapファイル
    • このファイルはiOSアプリのビットコードを有効にしている場合に必要。今回はビットコード有効の前提で進める

6. 以下のコマンドを実行し、dSYMファイルの難読化を解除する

dsymutil --symbol-map bcsymbolmapファイルへのパス dSYMファイルへのパス

7. 以下のコマンドを実行し、シンボル化に必要な環境変数を設定

export DEVELOPER_DIR="/Applications/Xcode.app/Contents/Developer"

8. 以下のコマンドを実行し、ipsファイルをシンボル化する

/Applications/Xcode.app/Contents/SharedFrameworks/DVTFoundation.framework/Versions/A/Resources/symbolicatecrash {対象のipsファイルのパス} {対象のdSYMのパス}

結果

ipsファイルのスタックトレースにエラーが発生したclass名/fucn名が表示される

シンボル化後のipsファイルスタックトレース抜粋
Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   libswiftCore.dylib                  0x00000001b02cc398 _assertionFailure+ 201624 (_:_:file:line:flags:) + 1504
1   libswiftCore.dylib                  0x00000001b02cc398 _assertionFailure+ 201624 (_:_:file:line:flags:) + 1504
2   test                                0x0000000104b3996c @objc ViewController.didTapErrorButton(_:) + 22892 (<compiler-generated>:14)
3   UIKitCore                           0x00000001af1e5ca4 -[UIApplication sendAction:to:from:forEvent:] + 96
8
4
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
8
4