Apple deprecated Garbage Collection with the release of Mountain Lion (OS X 10.8), in favour of ARC, the supposedly ‘killer’ memory management solution… we’ll see[1]

Is GC (Garbage Collection) deprecated on the Mac?

Garbage collection is deprecated in OS X Mountain Lion v10.8, and will be removed in a future version of OS X. Automatic Reference Counting is the recommended replacement technology. To aid in migrating existing applications, the ARC migration tool in Xcode 4.3 and later supports migration of garbage collected OS X applications to ARC.

Reading this, you’d have thought that Apple would be quick to jump on board the ARC bandwagon but alas it appears not in the case of Xcode.

Today I was trying to load a SIMBL plugin into XCode, only to be left with an error:

16/01/2013 12:24:05.865 Xcode[49450]: Error loading SIMBL:  dlopen(SIMBL, 262): no suitable image found.  Did find: SIMBL: GC capability mismatch

GC compatibility mistmatch? SIMBL isn’t built with Garbage collection enabled, so there must be something fishy here right? Indeed there is. If you run otool on the XCode app, all will be revealed:

$ otool -oV /Applications/Xcode.app/Contents/MacOS/Xcode

Look down to the __objc_imageinfo section, and you’ll see:

flags 0x6 OGJC_IMAGE_SUPPORTS_GC

After a bit of searching and stumbling upon some of Apple’s source code (thanks for making it open source guys), it turns out that this means the image supports Garbage collection and only Garbage Collection:

/* OBJC_IMAGE_SUPPORTS_GC:
    was compiled with -fobjc-gc flag, regardless of whether write-barriers were issued
    if executable image compiled this way, then all subsequent libraries etc. must also be this way
*/

So SIMBL or any other plugins/frameworks that you want to load into XCode must also be GC, ah well. We’ll give you a bit more time Apple to transition XCode to ARC, just make it quick 😉

It’s funny how, in a bizarre twist of events, the application that transitions GC code to ARC code for you hasn’t been through it’s own process.


Coming from a manual memory management background, ARC seems a bit scary to me; can it really deal with everything?! More importantly, it doesn’t solve any multithreading issues which have plagued us all for years