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

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -