LoginSignup
9

More than 5 years have passed since last update.

Swiftをコマンドラインから実行する

Last updated at Posted at 2014-10-26

"Swift command line" でググるとQiitaのこの記事がトップにでてくる。

Swiftをコマンドラインから実行
http://qiita.com/smurakami/items/a11643cf2cb93df27720

なるほど、なるほど。コマンドラインで叩けるExecutableがXcodeに入っているのでそれを探しだしてパスを通すと。

ちなみに、

$ find /Applications/Xcode.app -name swift | grep /bin/swift

$ find /Applications/Xcode.app -path \*/bin/swift -print

でも良い気が。

ともかく、これを設定しようと思ったが何気にコマンドラインで"swift"と打ってみると

$ swift
Welcome to Swift!  Type :help for assistance.
  1>

と出る。あれ、と思ったが確かにある。

$ which swift
/usr/bin/swift

で、調べてみるとこれっぽい。
https://developer.apple.com/library/ios/documentation/DeveloperTools/Conceptual/WhatsNewXcode/Articles/Introduction.html

Xcode 6.1 Update

Xcode 6.1 adds development support for OS X version 10.10 Yosemite and other feature additions.

  • Includes SDKs for OS X version 10.9, OS X version 10.10, and iOS 8
  • Adds Swift for OS X, including support for playgrounds, REPL, and command line scripts
  • Interface Builder adds Storyboards for OS X For additional details on the Xcode 6.1 release, see Xcode Release Notes.

ということで、「Swiftをコマンドラインから実行する」のalternative solutionとして

  • Xcode 6.1にアップグレードする

というのを挙げておきます

(10/26 追記)
どうやらこれはYosemite(OS X 10.10)限定の様で、Maveriks(OS X 10.9)ではこれまで通り/usr/binにはインストールされない様です。 [thanks to @riocampos]

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9