Debugging UTF-16 strings in XCode
November 17, 2006

It's been a while since I used XCode, so I was a bit baffled when debugging recently when I couldn't find a way to view a wchar_t* based string.

Surely there must be a way?

As it turns out, there isn't a way to do this that's built in to XCode (amazing!), but XCode can be extended with plugins, and Apple provide a sample plugin that does what I wanted.

To save everyone else going through the same length process that I've just gone through, here's how you do it:

You can get the sample project from http://developer.apple.com/samplecode/WcharDataFormatter/.

Build it with XCode (I built the debug version), and copy the resulting wchardataformatter.bundle into "/Library/Application\ Support/Apple/Developer Tools/CustomDataViews/".

One pitfall to look out for - it appears that the bundle has to be built for the native architecture that you're running on. By default, the project is set up to build for ppc, so if you're on Intel you'll need to change this to i386.

Once you've installed the plugin and restarted Xcode, you should find that when viewing any wchar_t or wchar_t* string, the Summary column in the debugger contains the correct character/text.

« Codewarrior Nostalgia with XCode XCode auto completion is rubbish »
Got a comment on this post? Let us know at @elegantchaoscom.