Reputation: 902
I am developing a library in Objective-C that targets all the Apple OSs (macos, ios, watchos, tvos). Some of the Apple APIs I use only available starting at a certain version of an OS. I do guard my interface definitions and OS version dependent code with:
API_AVAILABLE(macos(10.11), ios(9.0), watchos(2.0), tvos(9.0))
However, my module imports also seem to cause Cocoapods based builds of my library to fail.
For example, if the OSLog module is only available in OSs starting at versions according to the API_AVAILABLE(...) specification above, I do need to guard the @import OSLog;
with an #if precompiler condition similar to the API_AVAILABLE(...) above.
Assuming my assumption is correct, how should I exactly do it?
Upvotes: 1
Views: 378
Reputation: 16976
I think the following should work:
#if __has_include(<os/log.h>)
#include <os/log.h>
#endif
Upvotes: 2