LoginSignup
97

More than 5 years have passed since last update.

[Swift][超入門]初心者向けはじめてのHelloWorld!

Last updated at Posted at 2014-09-14

話題のSwiftでアプリをつくれるようになるためQiitaに情報を更新していきたいと思っています。

まずはDownload

こちらからDLできます。
iOS Developer Programs(デベロッパプログラム)への登録が必要なのでご注意ください。

プロジェクトの作成

  1. プロジェクトの新規作成 まずXCodeを開いたら File>New>Project を選択。

Screen Shot 2014-09-14 at 9.54.53 PM.png

2. テンプレートの選択
次に作りたいアプリに合わせてテンプレが選べます。
今回は iOS>Application>Single New Application を選択。

Screen Shot 2014-09-14 at 9.55.08 PM.png

3. プロダクト名の決定
次にプロダクト名を設定します。Product Nameの中にHelloWorldと入力しましょう。

Screen Shot 2014-09-14 at 9.55.24 PM.png

4. 保存先の設定
デフォルトでは~/Applications内に保存されるそうです。
今回はこのままにしましょう。
Screen Shot 2014-09-14 at 9.56.18 PM.png

HelloWorldを出力

上記を全て終えるとプロジェクトが立ち上がります。
プロジェクト名>ViewController.swift を開きましょう。

Screen Shot 2014-09-14 at 9.56.37 PM.png

開いたら、
override func viewDidLoad()

という関数内に、
println("HelloWorld!")

を記述します。ソースは以下。

ViewController.swift
import UIKit

class ViewController: UIViewController {

    override func viewDidLoad() {
        println("HelloWorld!")
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
}

左上の実行ボタンをクリック!!

Screen Shot 2014-09-14 at 9.57.16 PM.png

右下のログにHelloWorldと出力されればOK!!
これでSwiftエンジニアデビュー!!

基本文法の分かりやすいまとめ記事を発見。

作って学ぶSwift/iOSアプリ入門

とても参考になりますので、これからこちらなどを参考に色々と試してみたいと思います。

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
97