This is a Heroku buildpack for Swift apps that are powered by the Swift Package Manager.
$ ls Procfile Package.swift Sources $ heroku create --buildpack https://github.com/vapor-community/heroku-buildpack.git $ git push heroku master remote: -----> Swift app detected remote: -----> Installing clang 5.0.0 remote: -----> Installing swiftenv remote: -----> Installing Swift 4.1.1 remote: -----> Building package (release configuration) remote: -----> Installing dynamic libraries remote: -----> Installing binaries
You can also add it to upcoming builds of an existing application:
$ heroku buildpacks:set https://github.com/vapor-community/heroku-buildpack.git
The buildpack will detect your app as Swift if it has a
Package.swift file in
Using the Procfile, you can set the process to run for your web server. Any binaries built from your Swift source using swift package manager will be placed in your $PATH.
Example Procfile for Vapor 2 apps:
web: Run --env=production --port=$PORT
Example Procfile for Vapor 3 apps (Swift 4.1 required):
web: Run serve --env production --hostname 0.0.0.0 --port $PORT
You can also customise the version of Swift used with a
in your repository:
$ cat .swift-version 4.1.1
.swift-version file is completely compatible with
NOTE: Since there are frequent Swift language changes, it's advised that you pin to your Swift version.
By default, the buildpack will use the
release build configuration to enable compiler optimizations. If you are experiencing mysterious crashes, you can try disabling them by setting the
debug, then redeploying.
$ heroku config:set SWIFT_BUILD_CONFIGURATION=debug $ git commit -m "Change to debug configuration on Heroku" --allow-empty $ git push heroku master ... remote: -----> Building package (debug configuration) ...
### Custom app folder
By default, the buildpack will use the root project folder to detect and build you app.
If you want to use a custom project folder set the
PROJECT_PATH Config Var to the relative app folder.
You can place custom scripts to be ran before and after compiling your Swift source code inside the following files in your repository:
This is useful if you would need to install any other dependencies.
Copy the snippet above into CLI.