-mgtww
Last Updated: February 25, 2016
·
5.311K
· kattrali

Debugging Xcode Plugins

The (short) guide for Xcode plugin debugging, based on my experiences working on Alcatraz package manager and DerivedData Exterminator

Attach LLDB to Xcode by its process ID:

xcode-debug() {
  lldb -p `ps aux | grep Xcode | grep -v grep | awk '{print $2}'`
}

Add the xcode-debug function and a handy alias to your dotfiles, since debugging Xcode is very Hotel California:

alias xcd='xcode-debug'

Add breakpoints to your plugin code for later inspection, using file names and line numbers:

(lldb) breakpoint set --file  BestXcodePlugin.m --line 45

Inspect all the things!

(lldb) po myObject
$0 = 0x0000000400131f00 <MyPluginObject: 0xabad1dea>

And when you crash Xcode, check out the system logs:

tail -b 5 -f /var/log/system.log

Useful Plugins for Development

  • Xcode Explorer lists and filters notifications emitted by Xcode, and displays view hierarchies
  • Plugin Console shows plugin log messages within the Xcode console

3 Responses
Add your response

6441

I have it on good authority that this will actually make the world implode.

over 1 year ago ·
9892

ps aux | grep Xcode | grep -v grep | awk '{print $2}'

or just pgrep Xcode ;)

over 1 year ago ·
11932

With xCode 5, you can "run" your plugin by configuring it to debug xCode itself :
Managed Schemes > Run > Info tab > Executable = Xcode.app

I was very surprised that xCode is able to debug itself without side effects.

over 1 year ago ·