How use and run Swift 2.3 on command line

后端 未结 1 670
予麋鹿
予麋鹿 2021-01-06 18:45

How do you start Swift on the command line? And how do you compile files on the command line with Swift 2.3? Since I updated to Xcode 8 I get Swift 3 by default.

<         


        
相关标签:
1条回答
  • 2021-01-06 19:39

    UPDATE

    To use Swift 2.3 prefix swift with toolchain selection via xcrun:

    xcrun --toolchain "com.apple.dt.toolchain.Swift_2_3" swift --version
    

    prints:

    Apple Swift version 2.3 (swiftlang-800.10.12 clang-800.0.38)
    Target: x86_64-apple-macosx10.9
    

    OLD ANSWER

    Use swiftenv to install and switch between Swift versions.

    Install using Homebrew:

    brew install kylef/formulae/swiftenv
    

    Configure environment (zsh, for example):

    echo 'if which swiftenv > /dev/null; then eval "$(swiftenv init -)"; fi' >> ~/.zshrc
    

    List available versions:

    swiftenv install --list
    

    Install Swift 2.2:

    swiftenv install 2.2
    
    0 讨论(0)
提交回复
热议问题