Oh sure. Objective-C is a strict superset of C, so C macros are very at your disposal, and this tool is just a collection of C macros that eventually expand to gcc __attribute__ to declare special function attributes .
Relevant declarations are in
To update, you use the __OSX_AVAILABLE_STARTING macro to mark the function declaration as supported for a specific version, for example:
extern void mymacfunc() __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_NA);
So what do we need to implement this? If you separate their support for two different OS (mac, iphone), the availability of features boils down to:
A macro that takes a version argument, for example __MY_AVAILABLE_STARTING(<version>) :
#define __MY_AVAILABLE_STARTING(_myversion) __MY_AVAILABILITY_INTERNAL##_myversion
A set of version arguments, for example, in Availability.h , which are valid arguments for the above:
#define __MYVER_2_0 20000 #define __MYVER_2_1 20100 #define __MYVER_2_2 20200 #define __MYVER_3_0 30000
Another set of macros, for example thos in AvailabilityInternal.h , which indicates what should happen for each version (regular support, outdated, inaccessible, weak, etc.). Again, this is a compiler function, see gcc docs (there are many other interesting options):
#define __MY_AVAILABILITY_INTERNAL__MYVER_2_0 __AVAILABILITY_INTERNAL_UNAVAILABLE #define __MY_AVAILABILITY_INTERNAL__MYVER_2_1 __AVAILABILITY_INTERNAL_WEAK_IMPORT #define __MY_AVAILABILITY_INTERNAL__MYVER_2_1 __AVAILABILITY_INTERNAL_REGULAR
And finally, where does the dollar end, macros that expand to the __attribute__ object.
For the ones I have above, you can just use Apple macros:
#define __AVAILABILITY_INTERNAL_DEPRECATED __attribute__((deprecated,visibility("default"))) #define __AVAILABILITY_INTERNAL_UNAVAILABLE __attribute__((unavailable,visibility("default"))) #define __AVAILABILITY_INTERNAL_WEAK_IMPORT __attribute__((weak_import,visibility("default"))) #define __AVAILABILITY_INTERNAL_REGULAR __attribute__((visibility("default")))
Or, of course, you can define your craziness.
C Macros are powerful stuff that is often overlooked. Good luck
ckhan
source share