安装 Vapor 进行 Swift 后端开发

Lee*_*fin 5 swift vapor

我刚刚开始快速后端开发。我注意到 Vapor 并安装了 swift 包管理器(Swiftenv)。我按照其说明通过以下方式安装 Vapor CLI:

wget cli.qutheory.io -O vapor
Run Code Online (Sandbox Code Playgroud)

但不断报错:

Resolving cli.qutheory.io... 138.197.255.240
Connecting to cli.qutheory.io|138.197.255.240|:80... connected.
HTTP request sent, awaiting response... 404 Not Found
2016-08-07 10:41:15 ERROR 404: Not Found.
Run Code Online (Sandbox Code Playgroud)

有人面临同样的问题吗?如何摆脱它?

我还尝试了另一种方法:

curl -L cli.qutheory.io -o vapor
Run Code Online (Sandbox Code Playgroud)

输出是:

% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100    38  100    38    0     0     21      0  0:00:01  0:00:01 --:--:--    21
Run Code Online (Sandbox Code Playgroud)

然后,我运行命令:

chmod +x vapor
Run Code Online (Sandbox Code Playgroud)

进而:

sudo mv vapor /usr/local/bin
Run Code Online (Sandbox Code Playgroud)

进而:

vapor self-update
Run Code Online (Sandbox Code Playgroud)

但我收到错误:

/usr/local/bin/vapor: line 1: error:1: command not found
Run Code Online (Sandbox Code Playgroud)

如何安装vapor CLI?

rus*_*net 2

Vapor 团队刚刚发布了新的设置工具。使用 xCode Beta 4,以下内容对我有用:

  • 移至您的项目文件夹
  • swiftenv local DEVELOPMENT-SNAPSHOT-2016-07-25-a
  • curl -sL toolbox.qutheory.io | bash
  • vapor build
  • vapor xcode
  • 然后系统会自动提示您在 xCode 中打开该项目。按y

然后您应该能够导入 Vapor 并开始玩。

如果这不起作用,请先检查 Vapor 状态: curl -sL check.vapor.sh | bash

然后逐字阅读这篇文章 [ https://stormpath.com/blog/tutorial-build-first-swift-web-app-vapor ] 。你必须要匹配他的swift开发快照版本,否则不行。