[Biococoa-dev] Xcode settings for cross-development

Charles PARNOT charles.parnot at stanford.edu
Sun Feb 27 02:17:13 EST 2005


OK, I just read the docs and I understand much better now.

* The SDK is chosen in the project settings. It applies to all the 
targets in the project. The SDK is used to compilation and linking; 
for instance, if you use NSIndexSet with SDK = 10.2.8, you get a 
compiler error, because it is not found in <Cocoa/Cocoa.h>. In fact, 
the header being used is in /Developer/SDKs/MacOSX.2.8.sdk and not 
the one on your system, that's why. This is set with the environment 
variable SDKROOT.

* The Mac OS X Deployment target, however. can be set for each 
individual target. This is a different setting, which sets on which 
version the code will run. If you choose 10.2, your code will load in 
10.2 and higher. However, it does not mean it will run without 
crashes. For instance, if you were using the 10.3 SDK, and used 
NSIndexSet somewhere in your code, you don't get compiler warning, 
the program loads and runs fine until it hits that piece of code and 
then the program may crash when run on 10.2 (basically NSIndexSet is 
replaced with nil). Maybe you still want to use NSIndexSet, but only 
when running on X.3, and simply skip the code when running 10.2 (the 
app then misses some features). To allow that, you can dynamically 
check the version at runtime and only run the code using NSIndexSet 
if the system is 10.3+.

* I repeat: you can have the SDK set to 10.3 and still have code that 
loads fine in 10.2 if the Deployement target is set to 10.2. AS long 
as you don't use APIs specific for 10.3, the code will run fine.

* However, you cannot have the SDK set to 10.2 and the Deployement 
target to 10.3. The compilation will fail early.

* The way the project is set now, the SDK chosen in the project 
settings is 10.2.8 but it is actually NOT used for the 
BioCocoa.framework build!! The BioCocoa framework still uses the 10.3 
APIs despite that setting because it is an old format target and does 
not recognize the SDKROOT environment variable.
For instance, I tried to define an NSIndexSet * variable in the 
BioCocoa code with the SDK set to 10.2.8, and I had no compilation 
error!! This is because the targets are old-format. If you do the 
same with the new target I added, which is in the new format, you DO 
get a compilation error, telling you that NSIndexSet is undefined.
Bottom line: we should update all the targets to native format to 
take into account the SDKs and get the compilation warnings as 
appropriate.

* New format target = 'native target' won't open in Project Builder. 
This won't be a problem as everybody seems to be using Xcode (at 
least Alex, John, Koen and me).

* OCUnit works best with X.3-only frameworks because it uses the 
latest exception handling system. This does not mean the framework 
being tested need to be 10.3 only. Only the test framework needs to 
be X.3 only. In other words, the target 'BioCocoa' can be 10.2+, and 
the target 'BCFoundation-Tests' should be 10.3+. So the SDK has to be 
set to 10.3 to be able to compile the test framework... But then the 
SDKs will also be 10.3 for the BioCocoa framework...


The bottom line is:

* We may have to set the SDK to 10.3 because of the test framework

* I may find a way around it

* We will probably have to set the SDK to 10.3 at some point (e.g. 
for the BCAppKit --> bindings)

* Setting the SDK to 10.3 will not prevent the BioCocoa framework to 
load and run in 10.2.8, but we will not get compiler warnings if 
using APIs 10.3-only. For instance, if somebody uses NSIndexSet, 
there won't be any compiler warning.

* Future versions of Xcode might address that limitation.


Last update:
I just found a very simple solution to have one SDK per target: add 
an SDKROOT entry to the build settings. For instance, I set the SDK 
to 10.2.8 in the project and set SDKROOT to 
'/Developer/SDKs/MacOSX.3.0.sdk' in the target 'BCFoundation-Tests' 
and it ignored the project settings and compiled fine!!! An 
alternative is to even set SDKROOT to '/', in other words use the 
APIs of the current computer, which is 10.3 in my case (so I get the 
10.3.8 APIS, and not just 10.3.0 if that makes any difference).
Yeehouu!! I will be able to sleep tonight!!!

If anybody read all the way to here, let me know if something is 
still unclear ;-)

charles

-- 
Help science go fast forward:
http://cmgm.stanford.edu/~cparnot/xgrid-stanford/

Charles Parnot
charles.parnot at stanford.edu

Room  B157 in Beckman Center
279, Campus Drive
Stanford University
Stanford, CA 94305 (USA)

Tel +1 650 725 7754
Fax +1 650 725 8021



More information about the Biococoa-dev mailing list