I was going to try out Vapor 4 and followed the instructions here: Vapor: Install → macOS .
However, it seems that Homebrew is required when installing Vapor 4 on the Mac. Since I am a long time MacPorts user and Homebrew and MacPorts don't go well with each other (concurrent installation is not recommended), I am currently out of the loop.
So my question is: are there any plans to support MacPorts in the future? Or is there an alternate way to install Vapor 4 without using Homebrew?
If you feel comfortable learning the Swift Package Manager commands and executing those instead, then you can completely ignore the Vapor CLI for working with Vapor.
Much of it is shorthand for underlying SPM commands or speeding up project bootstrapping.
You're going to have problems unfortunately. MacPorts screws up the path of various things that SwiftPM uses when building dependencies, causing weird errors with NSCurses. I would love to say it's all good, but every time sometime tries to get going with Vapor having installed MacPorts it doesn't end well. You may be able to get it to work though, be interested to hear how you get along!
vapor build.-> swift build vapor run -> swift run vapor update -> swift package update vapor xcode -> Don't use this anymore with Xcode 11, just do open Package.swift
However when I type swift --version at the command line I still get:
Apple Swift version 5.1.3 (swiftlang-1100.0.282.1 clang-1100.0.33.15)
Target: x86_64-apple-darwin19.3.0
I tried a subsequent xcode-select --install but that didn't help either (said: error: command line tools are already installed, use "Software Update" to install updates).
Another way is xcrun --toolchain "Swift Development Snapshot" --run swift (replace “Swift Development Snapshot” with the name of the toolchain you want to use) if you want to use a specific toolchain.
tar -xvf /Users/lars/Downloads/toolbox-18.0.0-beta.27.tar.gz
install the dependency openssl: sudo port -v install openssl
cd toolbox-18.0.0-beta.27/
export TOOLCHAINS=swift
swift build --disable-sandbox
this went fine besides some warnings about UnsafeMutablePointers
mv .build/debug/vapor vapor-beta
./vapor-beta --help
which resulted in:
Usage: ./vapor-beta <command>
Vapor Toolbox (Server-side Swift web framework)
Commands:
supervisor Commands for working with Supervisord
xcode Opens an app in Xcode.
new Generates a new app.
heroku Commands for working with Heroku
build Builds an app in the console.
run Runs an app from the console.
clean Cleans temporary files.
Use `./vapor-beta <command> [--help,-h]` for more information on a command.
SLPN-NB-LSH:toolbox-18.0.0-beta.27 lars$ cd ../Documents/Projects/
SLPN-NB-LSH:Projects lars$ mkdir vapor-test
SLPN-NB-LSH:Projects lars$ cd vapor-test/
SLPN-NB-LSH:vapor-test lars$ ~/toolbox-18.0.0-beta.27/vapor-beta new hello -n
Cloning template...
name: hello
Would you like to use Fluent?
y/n> no
fluent: No
Generating project files
+ Package.swift
+ main.swift
+ configure.swift
+ routes.swift
+ .gitkeep
+ AppTests.swift
+ Dockerfile
+ docker-compose.yml
+ .gitignore
+ .dockerignore
Creating git repository
Adding first commit
**
**~~**
**~~~~~~**
**~~~~~~~~~~**
**~~~~~~~~~~~~~~**
**~~~~~~~~~~~~~~~~~~**
**~~~~~~~~~~~~~~~~~~~~~~**
**~~~~~~~~~~~~~~~~~~~~~~~~**
**~~~~~~~~~~~~~~~~~~~~~~~~~~**
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
**~~~~~~~~~~~~~~~~~~~~~~~~~~~~**
**~~~~~~~~~~~~~~~~~~~~~++++~~~**
**~~~~~~~~~~~~~~~~~~~++++~~~**
***~~~~~~~~~~~~~~~++++~~~***
****~~~~~~~~~~++++~~****
*****~~~~~~~~~*****
*************
_ __ ___ ___ ___
\ \ / / /\ | |_) / / \ | |_)
\_\/ /_/--\ |_| \_\_/ |_| \
a web framework for Swift
Project hello has been created!
Use cd hello to enter the project directory
Use vapor xcode to open the project in Xcode
SLPN-NB-LSH:vapor-test lars$ cd hello/
SLPN-NB-LSH:hello lars$ open Package.swift
everything went fine so far, Xcode opened and the project was there.
But I could not run it. I've got the following error:
/Users/lars/Documents/Projects/vapor-test/hello/Package.swift: package at '/Users/lars/Documents/Projects/vapor-test/hello' is using Swift tools version 5.2.0 but the installed version is 5.1.0
despite having the new 5.2 toolchain selected in Xcode > Toolchains
How can I convince Xcode to use the selected 5..2 toolchain?