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

Popular posts from this blog

maven fortify plugin : Unable to load build session with ID XXXXX .. See log file for more details -

c# - Primavera WebServices does not return any data -

android - Display emoji panel with genymotion - keyboard/touch input? -