Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot Deploy To Vapor Cloud with Swift 4

I try to deploy hello world app for testing purpose. I check my swift tools version and it's 4.0

acme-iMac:HelloWorldWeb johndoe$ swift --version
Apple Swift version 4.0 (swift-4.0-RELEASE)
Target: x86_64-apple-macosx10.9

I also use swiftenv and it's point to version 4.0 as well.

acme-iMac:HelloWorldWeb johndoe$ swiftenv version
4.0 (set by /Users/johndoe/Vapor/HelloWorldWeb/.swift-version)

The Package.swift file also seems fine

// swift-tools-version:4.0

import PackageDescription

let package = Package(
    name: "HelloWorldWeb",
    products: [
        .library(name: "App", targets: ["App"]),
        .executable(name: "Run", targets: ["Run"])
    ],
    dependencies: [
        .package(url: "https://github.com/vapor/vapor.git", .upToNextMajor(from: "2.2.0")),
        .package(url: "https://github.com/vapor/leaf-provider.git", .upToNextMajor(from: "1.1.0")),
    ],
    targets: [
        .target(name: "App", dependencies: ["Vapor", "LeafProvider"],
               exclude: [
                   "Config",
                   "Database",
                   "Public",
                   "Resources"
               ]),
        .target(name: "Run", dependencies: ["App"]),
        .testTarget(name: "AppTests", dependencies: ["App", "Testing"])
    ]
)

But every time I try to vapor cloud deploy, it always failed.

Creating deployment [Done]
Connecting to build logs ...
Waiting in Queue [Done]
Checkout branch 'master' [Done]
Verifying base folder [Done]
Selected swift version: 3.1.0 [Done]
Selected swift version: 3.1.0 [Done]
Building vapor [Failed]
swift-build: error: Package requires minimum Swift tools version 4.0.0. Current Swift tools version is 3.1.0

Error: deploy failed.

The app run successfully on local machine.

like image 246
Seto Avatar asked Jan 30 '23 03:01

Seto


1 Answers

Vapor Cloud needs to be told to use Swift 4; it defaults to 3.1.

Add a file named cloud.yml to the root directory of your project, containing:

type: "vapor"
swift_version: "4.0.0"
like image 126
tobygriffin Avatar answered Jan 31 '23 22:01

tobygriffin