I have the most recent version of Xcode 9 installed and have reinstalled vapor with brew a couple times now, but I'm still getting the following error whenever I try to build/run/update the project.
Here's what I'm working with
1.) Vapor Toolbox: 3.1.2
2.) Apple Swift version 4.0 (swiftlang-900.0.43 clang-900.0.22.8)
Target: x86_64-apple-macosx10.9
3.) Xcode 9.0
Build version 9M136h
Error: Could not generate Xcode project: error: manifest parse error(s):
/var/folder/60/n3ldjzgs5vsg06v17_1yy44h0000gn/T/TemporaryFile.VwrbJo.swift:41:5
: error: argument 'targets' must preceed argument 'dependencies'
targets" [
^
error: The product dependency 'Vapor' was not found.
error: The product dependency 'FluentProvider' was not found.
error: The product dependency 'Testing' was not found.
Here is my Package.swift file. Looking at my original error, I did try switching the 'targets' and 'dependencies' order in which they appear in the file. This didn't solve anything and produced the following error message: error: argument 'dependencies' must precede argument 'targets'
Package.swift
let package = Package(
name: "test",
products: [
.library(name: "App", targets: ["App"]),
.executable(name: "Run", targets: ["Run"])
],
dependencies: [
.package(url: "https://github.com/vapor/vapor.git", .upToNextMajor(from: "2.1.0")),
.package(url: "https://github.com/vapor/fluent-provider.git", .upToNextMajor(from: "1.2.0")),
],
targets: [
.target(
name: "App",
dependencies: ["Vapor", "FluentProvider"],
exclude: [
"Config",
"Public",
"Resources",
]
),
.target(name: "Run", dependencies: ["App"]),
.testTarget(name: "AppTests", dependencies: ["App", "Testing"])
]
)
Xcode 12 / Swift 5.3 Update
vapor
is now part of homebrew/core
. Source: github homebrew-core/Formula/vapor.rb.
##### If applicable, remove the obsolete 'vapor/tap' #####
## List current taps:
brew tap
# homebrew/core
# vapor/tap
## Remove tap:
brew untap vapor/tap
#### Install current version of vapor #####
brew install vapor
brew upgrade vapor
Xcode 9 / Swift 4
Double Check Versions: "the most recent releases" would be at least Xcode 9.1 (9B55) and Apple Swift 4.0.2 (swiftlang-900.0.69.1 clang-900.0.38)
Verify that the first line in Packages.swift
is // swift-tools-version:4.0
. Without swift-tools-version
line, Packages.swift could be processed as swift-tools-version 3. which will cause an error.*
cd _PROJECT_PATH_
swift package tools-version
# if not 4.0.0, then …
swift package tools-version --set-current
An example, Package.swift is shown below. See Swift Package Manager Manifest API Redesign and swift-package-manager Usage Documentation for additional information.
// swift-tools-version:4.0
// The swift-tools-version declares the minimum version of Swift
// required to build this package.
// Syntax: '// swift-tools-version:<specifier>' on the 1st line
import PackageDescription
let package = Package(
name: "test",
products: [
.library(name: "App", targets: ["App"]),
.executable(name: "Run", targets: ["Run"])
],
dependencies: [
.package(url: "https://github.com/vapor/vapor.git", .upToNextMajor(from: "2.3.0")),
.package(url: "https://github.com/vapor/fluent-provider.git", .upToNextMajor(from: "1.3.0")),
],
targets: [
.target(
name: "App",
dependencies: ["Vapor", "FluentProvider"],
exclude: [
"Config",
"Public",
"Resources",
]
),
.target(name: "Run", dependencies: ["App"]),
.testTarget(name: "AppTests", dependencies: ["App", "Testing"])
]
)
cd _PROJECT_PATH_
swift package tools-version
# should be 4.0.0
vapor clean
vapor update
vapor --version
# Vapor Toolbox: 3.1.2
# Vapor Framework: 2.3.0
More notes are posted on StackOverflow here for using Xcode 9 and Swift 4 with Vapor 2.
The GitHub repository Vapor Examples Lab has several example projects which have been migrated to Vapor 2 and Swift 4.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With