CatHand Blog

アプリ開発やMac弄り

Xcode12.5でCould not attach to pidエラー

久しぶりにMacアプリのプロジェクトを開いて実行しようとしたら以下のようなエラーでデバッガ接続できなくなっていました。

f:id:cathandnya:20210525101528p:plain

Could not attach to pid : “1948”
Domain: IDEDebugSessionErrorDomain
Code: 3
Failure Reason: attach failed (Not allowed to attach to process.  Look in the console messages (Console.app), near the debugserver entries when the attached failed.  The subsystem that denied the attach permission will likely have logged an informative message about why it was denied.)
User Info: {
    DVTRadarComponentKey = 855031;
    RawUnderlyingErrorMessage = "attach failed (Not allowed to attach to process.  Look in the console messages (Console.app), near the debugserver entries when the attached failed.  The subsystem that denied the attach permission will likely have logged an informative message about why it was denied.)";
}

色々調べた結果、Build Settingsの Enable Hardened RuntimeYes になっていました。この設定は Apple の公証を取得するために必要なんですが、Debug実行では必要ないので、 No にします。

f:id:cathandnya:20210525101914p:plain

するとエラーにならずデバッグ実行できるようになりました。