For example, some api of cocoa is deprecated after macOS 10.10, and the new one is introduced after macOS 10.10. My question is if my app needs run on macOS 10.8 and later(10.9,10.10,10.11,10.12), so I can use neighter of them. Am I right? If so, what I can do for this?
what I can do for this?
At the technical level you test for existence of the API and branch accordingly, in abstract:
if (10.10 API available)
{
// use 10.10 API
}
else
{
// use earlier API or handle not supporting feature
}
In Objective-C Apple recommends testing for availability by testing for the specific method (using respondsToSelector:
) or type (using weak linking); you can also test for a specific framework (recommended) or OS version (least favoured by Apple, often used by programmers...). If you get deprecation warnings, but you know the code is OK due to testing, you can locally suppress the warnings with #pragma
's.
In Swift Apple provides a test for OS family (macOS, iOS etc.) and version (#available
).
Regardless of language you build against the latest SDK you wish to support.
Obviously supporting a single codebase over many changes can get somewhat complex and/or messy, dealing with this is a business decision.
HTH