If you are a Cocoa or Cocoa Touch developer, you may have attempted to use features such as properties in GNUstep, only to be surprised that these don’t seem to be supported. This is because these are Objective-C 2.0 features.
To get the new features, the only way is to use a different compiler called clang. You may have seen this compiler used in newer releases of Xcode. This is a compiler that targets a virtual machine called LLVM before producing native code.
UPDATE May 4th 2011: GCC 4.6 has got the Objective-C 2.0 treatment, and since Debian includes GCC 4.6, I’d recommend you to try compiling your software that way. Not because it’s a better compiler — I have no idea which one works better — but because it’s there. Also, consider compiling GNUstep from trunk using GCC 4.6; it’s rather easy to do. (CC=gcc-4.6 ./configure, whenever compiling a component of GNUstep).
Let’s presume you managed to run an Objective-C program with GNUstep; that is, let’s presume you are aware of Project Center, or GNUmakefiles. If you are didn’t use GNUmakefiles, you should know that Project Center generates these in order to build your app.
Now you want to switch to clang, and you want to do so on your favorite operating system, Debian GNU/Linux.
apt-get install clang
Since some GNUstep files refer to
As of Dec 6th 2010, this is the package that needs to be installed:
apt-get install gobjc-4.3
You could also install gobjc-4.2, but let’s go with 4.3 for now.
We need to tell GNUstep to use the new compiler. We’ll need to edit one of template makefiles that GNUmakefile files use.
sudo $EDITOR /usr/share/GNUstep/Makefiles/config.make
Yes, that’s right: the easiest way I could find involves changing stuff in /usr (meaning upon package upgrade this might get overwritten — go figure).
Just below the license text, you should find the section “Binary and compile tools” which sets various variables such as CC, OBJCFLAGS, et cetera. Edit the relevant lines accordingly!
CC = clang OBJCFLAGS = -I/usr/lib/gcc/i486-linux-gnu/4.3/include CPP = clang -E
(Note the fugly path that we add to include path by setting OBJCFLAGS: We need to give clang the path to objc/objc.h; if one of them is different, edit the architecture name and gobjc version accordingly)
That’s it! @property, @synthesize and other friends you made while using Objective-C 2.0 under OS X are back in da hood, makin’ programming enjoyable once again. Plus, you get the extra build speed that clang provides, being somewhat faster than GCC.