I want to build an OSX application that will use some of the new 10.7 SDK features (more specifically, In-App purchases). However I don't want to completely prevent 10.6 users from installing the application.
How can I make it so that 10.7 users have access to the new features, and 10.6 users simply don't have the 开发者_JS百科new features but can still use the basic stuff?
When I compile for 10.6 it doesn't load the SDK that has "InApp", as expected. And I suppose if I compile for 10.7 users won't be able to install it from the AppStore.
You can use one of these methods to determine the user's OS version, then if they are running Lion, run the code, if they aren't don't run it (use an if statement)
Edit: You'll also have to weak link the storekit framework
Not sure if this helps, but for newer API's (such as those for Lion only) I just use an IF statement with respondToSelector:
This is one of the way suggested by Apple and you don't have to mess with knowing a particular OS during runtime.
Could you create a bundle that could get loaded and offer the 10.7 features? Your real app could check to see which OS it's running under and not load the 10.7 bundle. I don't know if this would work since it wouldn't be unreasonable for a 10.7-SDK bundle to refuse to load in a 10.6 SDK app.
Another possibility might be to have two apps under the hood, and have a very small shell app (possibly even a script) that detects the host OS and execs the OS-correct executable.
精彩评论