ios - How can I programmatically find Swift's version? -


i know can find version of swift i'm running right reverting terminal , typing:

xcrun swift --version swift version 1.1 (swift-600.0.57.4) target: x86_64-apple-darwin13.4.0 

also, i've been reading preprocessor macros in swift, no luck finding swift version constant.

as swift 1.2 approaches nice flag old code runs on swift 1.1 (xcode 6.2) or new code needs xcode 6.3 (swift 1.2)

note: can use system() like:

system("xcrun swift --version | grep version > somefile.txt") 

then open somefile.txt, rather prefer simpler solution

you can use conditional compilation directives test specific swift version used build project:

#if swift(>=3.0) print("hello, swift 3!") #elseif swift(>=2.2) print("hello, swift 2.2!") #elseif swift(>=2.1) print("hello, swift 2.1!") #endif 

Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -