当尝试使用Swift 3和Xcode构建Vapor 0.13(以及可能的其他版本)时
环境
Vapor: 0.13
Swift: 3
Snapshot: DEVELOPMENT-SNAPSHOT-06-20-A
Xcode: 8
Run Code Online (Sandbox Code Playgroud)
以下错误通常是第一个结果:
错误:Swift不支持SDK'MacOSX10.11.sdk'
我正在尝试在运行Ubuntu 15.10 x64的服务器上安装vapor(https://github.com/vapor/vapor)工具箱.
我从"swift build"命令中收到此错误
/swift-3.0/usr/bin/swift-build: error while loading shared libraries: libcurl.so.4: cannot open shared object file: No such file or directory
Run Code Online (Sandbox Code Playgroud)
这是卷曲问题吗?我该如何解决这个错误?
我按照这里描述的步骤操作:https: //vapor.github.io/documentation/getting-started/install-toolbox.html
已安装Swift 3.0:
user@server:~$ swift --version
Swift version 3.0 (swift-3.0-RELEASE)
Target: x86_64-unknown-linux-gnu
Run Code Online (Sandbox Code Playgroud)
要安装工具箱:
user@server:~$ curl -sL toolbox.vapor.sh | bash
? Compatible
Downloading...
Compiling...
/swift-3.0/usr/bin/swift-build: error while loading shared libraries: libcurl.so.4: cannot open shared object file: No such file or directory
Installing...
bash: line 22: .build/release/Executable: No such file or directory
Use …Run Code Online (Sandbox Code Playgroud) 我创建了一个 Swift 包管理器库,并将它部署在我的 GitLab 上,标签号为 0.1.0。我现在正在尝试通过添加以下内容将此包添加到我的新蒸气项目中:
.package(url: "http://mygit.git/", from: "0.1.0").
Run Code Online (Sandbox Code Playgroud)
当我尝试进行“蒸汽更新”时,我收到一个 backgroundExecute 错误,说我的 SPM 没有 0.1.0 版的清单……
有任何想法吗?提前致谢!
我在Body部分的文档中看到,现在支持文件上传 - 或者至少我是这样理解的
我在后端开发方面没有坚实的基础 - 特别是如果它涉及到仍然像Vapor那样快速发展的框架.我想知道是否有人可以提供文件上传的真实例子?我希望有一个简单的网页,可以将文件上传到后端,然后存储以备将来使用.
在服务器端swift的Vapor框架中,我想回复一个请求,其中包含我从第三方API获得的信息.例如,我收到一个询问城市温度的获取请求,我想连接到雅虎是否API获取温度然后将其发回.我需要下载像Alamofire这样的套餐吗?或者在Vapor中是否有内置方法可以这样做?
当我正在尝试登录时,我正面临着这个错误.
remote: /tmp/build_f459d376d1bc10ac2e93e52575ac5ea9/Sources/App/main.swift:368:49: error: argument type 'String' does not conform to expected type 'CVarArg'
remote: NSLog("FILE NOT AVAILABLE", "TESTNOTI")
remote: ^~~~~~~~~~
remote: as! CVarArg
Run Code Online (Sandbox Code Playgroud)
mycode的
if fileManager.fileExists(atPath: (drop.config["servers", "default", "KeyURL"]?.string ?? "default")) {
NSLog("FILE AVAILABLE", "TESTNOTI")
} else {
NSLog("FILE NOT AVAILABLE", "TESTNOTI")
}
Run Code Online (Sandbox Code Playgroud) Vapor 3似乎没有读取Config/server.json文件,因此我无法配置Vapor 3应用程序绑定的主机名和端口.
Vapor 3有不同的方法吗?
我在尝试安装Vapor的CTLS包时遇到以下错误.
Gertrude:ctls tanner$ brew install ctls
Error: No available formula with the name "ctls"
==> Searching for similarly named formulae...
Error: No similarly named formulae found.
==> Searching taps...
Error: No formulae found in taps.
Run Code Online (Sandbox Code Playgroud) 我对如何查询模型对象的子项并立即使用它感到困惑.我Client的Station儿子很多
final class Client: PostgreSQLModel {
var stations: Children<Client, Station> {
return children(\.clientID)
}
}
Run Code Online (Sandbox Code Playgroud)
然后在我的控制器中,我有一个客户列表,我想看看并抓住他们的电台.
func clientIndexHandler(_ req: Request) throws -> Future<View> {
return Client.query(on: req).all().flatMap(to: View.self) { clients in
let sorted = clients.sorted { ... }
let content = try sorted.map { client in
let stations = try client.stations
.query(on: req)
.all()
.map(to: [String].self) { stations in
return stations.map { $0.name }
}
// Now I want to use the stations for other stuff. …Run Code Online (Sandbox Code Playgroud) 刚开始使用Vapor 3和MySQL数据库,我很难搞清楚关系部分.
到目前为止我创建了2个模型:Movie和Actor.A Movie可以有很多Actors而且Actor可以有很多Movies.
Movie 模型:
import Vapor
import FluentMySQL
final class Movie: Codable {
var id: Int?
var name: String
var synopsis: String
var dateReleased: Date
var totalGrossed: Float
init(id: Int? = nil, name: String, synopsis: String, dateReleased: Date, totalGrossed: Float) {
self.id = id
self.name = name
self.synopsis = synopsis
self.dateReleased = dateReleased
self.totalGrossed = totalGrossed
}
}
extension Movie {
var actors: Siblings<Movie, Actor, MovieActor> { …Run Code Online (Sandbox Code Playgroud)