LoginSignup
4
5

More than 5 years have passed since last update.

Swift on Linux

Posted at

Swift on Linux

Linux 版の Swift2.2 がリリースされているので、それらを試食してみる。

Welcome to Swift.org

インストール

Linux の場合、tarball を取得して、そのまま展開、パスの設定だけすれば、REPLが利用可能になる。

サンプルコード

衝撃受けたのが、OS X 版と Linux 版とではコードの書き方が異なること。どうも Linux 名版の Swift は iOS、OS X のアプリケーションを記述する為の言語ではない模様。

import 文から、違うものを読み込んでる。まー仕方ないのかな。。。
On OS X

1> import Darwin
2> arc4random_uniform(10)
$R0: UInt32 = 4

On Linux

1> import Glibc
2> random() % 10
$R0: Int32 = 4

今日はここまで。。。また、明日。

4
5
0

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
4
5