views:

283

answers:

1

Hi,

I'm building an application that takes advantage of Mac OS X 10.6-only technologies, but without giving up backwards compatibility to 10.5 Leopard.

The way I do this is by setting the 10.6 SDK as the base SDK, weak-linking all frameworks and setting the deployment target to 10.5 as described in:

http://developer.apple.com/mac/library/DOCUMENTATION/MacOSX/Conceptual/BPFrameworks/Concepts/WeakLinking.html

This works fine; before making a call that is Snow Leopard-only I need to check that the selector or indeed the class actually exist. Or I can just check the OS version before making the call.

The problem is that this is incredibly fragile. If I make a single call that is 10.6 only I blow Leopard-compatibility. So using even the normal code code completion feature can be dangerous.

My question: is there any way of checking which calls are not defined on 10.5 before doing a release build? Some kind of static analysis, or even just a trick (a target set the other SDK?) would do.

I obviously should test on a Leopard machine before releasing anything, but even so I can't possibly go through all paths of the program before every release.

Any advice would be appreciated.

Best regards,

Frank

+1  A: 

You could change the target SDK to 10.5. The compiler will then output warning: definition for '-snowLeopardOnlyMethod:' not found messages.

Benedict Cohen
Thanks,I'm not sure I understand what I need to set to 10.5..I've got "Base SDK" set to 10.6 and "Deployment Target" is already set to 10.5. and there are definitely no snowLeopardOnlyMethod: warnings anywhere.Changing the Base SDK to 10.5 will of course produce lots of errors, but the problem is that there will be lots of errors and warnings that are due to earlier code not compiling and the compiler stops producing errors after a while, so even going by hand through the error messages might not catch every method to 10.6 only APIs.I'm sure I'm missing something, but where?
Frank R.
`snowLeopardOnlyMethod:` is just an example method name (it could have been `exampleMethod:`). I'd recommend reading http://developer.apple.com/mac/library/documentation/DeveloperTools/Conceptual/cross_development/Configuring/configuring.html to learn about the terminology Apple use.
Benedict Cohen
Hi Benedict, thanks for the link. I've read finished reading it. Apple talk about "deployment OS version" (aka MACOSX_DEPLOYMENT_TARGET) and "base SDK (aka SDKROOT). I assume by "target SDK", you mean the "base SDK"/SDKROOT. Setting the Base SDK to 10.5 according to Figure 2-1 on the document you linked would mean "Do not use these APIs" for Mac OS X 10.6 calls, which is why I have problems following your advice.Doing so temporarily then resetting the base SDK to 10.6 presents the problems I mentioned in my first comment.
Frank R.