Swift愛好会合宿 2018/1/20-1/21で記事書いてます。 #love_swift
Manual Quickstartを参考にVaporでWebサーバー立ててた時の内容です。
$ swift build
をしたときにエラーになりました。
$ swift build
error: manifest parse error(s):
/home/n0bisuke/myswift/webapp/Package.swift:11:10: error: type 'Package.Dependency' has no member 'Package'
.Package(url: "https://github.com/vapor/vapor.git", majorVersion: 2)
~^
$ swift build
error: manifest parse error(s):
/home/n0bisuke/myswift/webapp/Package.swift:10:10: error: ambiguous reference to member 'package'
.package(url: "https://github.com/vapor/vapor.git", majorVersion: 2),
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/n0bisuke/myswift/webapp/Package.swift:10:10: note: overloads for 'package' exist with these partially matching parameter lists: (url: String, from: Version), (url: String, Package.Dependency.Requirement), (url: String, Range<Version>), (url: String, ClosedRange<Version>), (url: String, version: Version), (url: String, branch: String), (url: String, revision: String), (url: String, range: Range<Version>)
.package(url: "https://github.com/vapor/vapor.git", majorVersion: 2),
^
他も見てるとSwift3系までのPackage.Swiftでの例が多いので注意が必要そうです。
3系と4系のPackage.swift
- 3系
// swift-tools-version:3.1
import PackageDescription
let package = Package(
name: "Hello",
dependencies: [
.Package(url: "https://github.com/vapor/vapor.git", majorVersion: 2)
]
)
- 4系
// swift-tools-version:4.0
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "webapp",
dependencies: [
// Dependencies declare other packages that this package depends on.
.package(url: "https://github.com/vapor/vapor.git", from: "2.4.0"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
.target(
name: "webapp",
dependencies: ["Vapor"]),
]
)
ざっくりと、.Package
は.package
に、 majorVersion
はfrom
に変更するところです。
Swift Package Manager Manifest API Redesignなど参考にすると良さそうです。