519A bit about Frameworks and Static Libraries on the iPhone

Frameworks are a way to share code and other resources between application. As sharing code between applications is not really possible on the iPhone (as is dynamic loading of libraries) it does not really make much sense to use Frameworks on the iPhone - except maybe for the nice handling of reusable code.

Where with Frameworks the specific files are accessable after the Framework is added to a project, working with Static Libraries is a bit more of an hussle. You not only need to add the library, but also need to make sure to set the right Header Search Paths, which can become troublesome when working with SVN'ed projects.

And because the architecture differs on the iPhone (ARM) and the Simulator (i386), having precompiled libraries is not the best solution. But adding a depended library project to your projects kind of negates the advantages of having reusable code by adding unnecessary complications.

Recommendation? Just add the desired files to your project. And if you really mind, don't copy, but only include by reference.

492Target Conditionals

TargetConditionals.h

#include ;

// Gives you TARGET_IPHONE_SIMULATOR and TARGET_OS_IPHONE target conditionals.
// Set hello to "Hello, "!
#if TARGET_IPHONE_SIMULATOR
   NSString *hello = @"Hello, iPhone Simulator!";
#else
   NSString *hello = @"Hello, iPhone device!";
#endif

//Determining whether you’re compiling for the iPhone OS
#if TARGET_OS_IPHONE
   #import 
#else
   #import 
#endif

Conditionalizing Compilation and Linking from the Apple Dev Library.

I came across a simple and short IPHONE target conditional at some framework, but that did not seemed to do the trick. I am probably missing something there.

-

Update 1. tconf might be a step into the right directions.

Just out of curiosity, here a incomplete list of available target conditionals:

TARGET_IPHONE_SIMULATOR
TARGET_CARBON
TARGET_OS_IPHONE
TARGET_CPU_PPC 
TARGET_CPU_PPC64
TARGET_CPU_68K
TARGET_API_MAC_OSX
PRAGMA_ALIGN_SUPPORTED
TARGET_OS_UNIX
TARGET_OS_EMBEDDED
TARGET_OS_MAC
TARGET_OS_WIN32
TARGET_OS_UNIX
TARGET_OS_EMBEDDED
TARGET_RT_MAC_CFM
TARGET_RT_MAC_MACHO
...

Update 2. And that's the motherload. Nice of Apple to open-source that.