I'd like to implement automated unit tests in a Hudson server on a Linux machine, but I'm not sure whether I can compile and test code that imports Foundation.h on Linux.
Good news! Yes, you can. :-)
If your primary goal is testing Cocoa code, keep in mind that there may be differences between GNUstep and Cocoa. But, everyone should be writing code that runs on both GNUstep and Cocoa, anyway, so that's not a problem, right? :-)
Here's my question: Is it true that GNUstep will compile Foundation.h, but not the graphical libraries? I think that would work, since I can't effectively test the graphical components with unit tests, anyway. GNUstep has its own graphical libraries for cross platform application development, right?
Sure.
Foundation is implemented in gnustep-base.
AppKit is implemented in gnustep-gui (and, to actually get stuff on the screen, gnustep-back).
To compile a console-only app, simply don't link in gnustep-gui and don't include anything from the AppKit framework.
If you are only getting started, you'll need to install just the gnustep-base package from your distribution; under Debian and Ubuntu it pulls all the dependencies in (and there are more up to date packages available as well).
Otherwise, you'll need to:
- install all the dependencies
- compile and install gnustep-make
- compile and install gnustep-base
Chime in if you decide to be on the bleeding edge; I have a handy script around, if you're on Debian or Ubuntu.
Then, you'll need to "source" the GNUstep.sh script which prepares the bash environment for GNUstep development. Under Debian, the line may read (note the dot):
. /usr/share/GNUstep/Makefiles/GNUstep.sh
Then, write a GNUmakefile for your app, in place of an .xcodeproj. (You could use ProjectCenter, but writing GNUmakefiles directly is better long-term.)
Nicola Pero has some nice tutorials on writing GNUmakefiles, as well as writing command line tools and apps with GNUstep, over here:
Any other thoughts about using Linux to unit test objective-c code? Is my plan feasible? I'm open to other options. I can purchase another Mac for Hudson/automatic unit testing, but I'd prefer to run my objective-c unit tests on a Linux machine, because of the difference in price.
You'll want to occasionally run the tests on the Mac as well. GNUstep is very similar to Cocoa (and has not only chased it, but hunted it down, in many most important areas -- especially in gnustep-base/Foundation). But it still isn't exactly Cocoa.
Which doesn't mean you should look away from GNUstep for your current and future needs; it's still worth your time.
Set up Hudson under Linux, and occasionally doublecheck whether the tests work under Cocoa, and you're good to go. Get familiar with the ecosystem, and find ways to leverage GNUstep. More real life use we get, healthier the society :-)