LoginSignup
1
2

More than 5 years have passed since last update.

swiftサーバーサイドであるperfectの入門についてのまとめ

Last updated at Posted at 2017-03-06

はじめに

本家のGetting standardを元にやっていきます

実行環境

PC MacBook Pro (Retina,13-inch,Mid 2014)
swift version 3.0.2
OS macOS Sierra 10.12.3
XCode 8.2.1

導入方法

まずPerfectTemplateをクローンします

git clone https://github.com/PerfectlySoft/PerfectTemplate.git

その後ディレクトリを移動し、ビルドをしてソケットを解放します

cd PerfectTemplate
swift build
.build/debug/PerfectTemplate

おそらく

[INFO] Starting HTTP server localhost on 0.0.0.0:8181
[INFO] Starting HTTP server localhost on 0.0.0.0:8080

と出てくると思うので、

0.0.0.0:8080に移動し、Hello, world!とブラウザに表示されれば成功です

いままのままではXCodeで開けないので、クローンしてきたプロジェクトをXCodeのプロジェクトにします

swift package generate-xcodeproj

と実行するとPerfectTemplate.xcodeprojを作成されます

XCodeでの実行

まず.build/debug/PerfectTemplateの実行を止めます

次にXCodeで開いたものを実行します

ビルドターゲットが2つありますが、
スクリーンショット 2017-03-06 21.59.08.png

上の方はただのビルド?で下のexecの方は.build/debug/PerfectTemplateの実行まで行ってくれます

よって、カバンの方でビルドした場合、改めて.build/debug/PerfectTemplateを実行する必要があります

1
2
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
1
2