macros - How do I write universal swift code for both iOS and OS X. In cocoa I could use #ifdef, what do I do now? -
macros - How do I write universal swift code for both iOS and OS X. In cocoa I could use #ifdef, what do I do now? -
for our project used 1 source file both platforms: ios , os x. right migrating swift. unfortunately there files need
import cocoa
and on ios
import uikit
previously did
#ifdef __mac_os_x_version_max_allowed #import <cocoa/cocoa.h> #else #import <uikit/uikit.h> #endif
do know how can done in swift? don't write each class twice because there no macros anymore.
thanks in advance
jack
use:
#if os(osx) import cocoa #elseif os(ios) import uikit #endif
macros swift import preprocessor conditional-compilation
Comments
Post a Comment