LoginSignup
9
8

More than 5 years have passed since last update.

デバッガでSwiftコードの変数の中身が見えなくなった時に確認すること

Posted at

Objective-C・Swift混在環境において、デバッガでSwiftコード上の変数の中身が見れなくなってしまう問題の対処方法です。具体的な症状としてはlldbコンソールでpoを叩くと以下のようなエラーが表示されます。

(lldb) po self.anyVariable
warning: Swift error in module Debug.
Debug info from this module will be unavailable in the debugger.

error: in auto-import:
failed to get module 'Debug' from AST context:

1. Bridging headerに不要なものを書いていないか

Swift側にブリッジする必要のないヘッダがimportされているとこのような症状が起こります。例えばBridging headerで以下のようにCocoaPodsライブラリのヘッダをimportしているとこの問題を引き起こす事があります。

App-Bridging-Header.h
#import <LibraryName/LibraryName.h>

2. ヘッダと実装ファイルで重複したimport文がないか

以下のようなケースです。重複していてもコンパイル警告は出ませんが、Bridging headerでこのヘッダを読み込んでいるとSwiftコードに影響が出るようです。

SomeCode.h
#import <LibraryName/LibraryName.h>
...
SomeCode.m
#import "SomeCode.h"
#import <LibraryName/LibraryName.h>
...

まとめ

Objective-C・Swift混在環境でのデバッガのトラブルについて対処方法を説明しました。同様の問題が起こった場合はヘッダ読み込み周りを見直してみるといいかもしれません。

9
8
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
9
8