Vapor 4 and MacPorts

Hi everybody,

I was going to try out Vapor 4 and followed the instructions here: .

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?

Thanks in advance!


1 Like

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!

1 Like

What are those commands? Are they somewhere documented, ideally as step by step instructions?

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

1 Like also says that Swift 5.2 is needed for Vapor 4. So I just downloaded and installed it. So far so good, I can now choose in Xcode > Toolchains which toolchain to use.

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).

Any idea?

Nevermind, found a solution here:

I just had to issue the following command:

export TOOLCHAINS=swift

now I get:

swift --version

Apple Swift version 5.2-dev (Swift 33150e32b4)

Target: x86_64-apple-darwin19.3.0

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.

After looking at I did the following:

  • downloaded then
  • openssl dgst -sha256 /Users/lars/Downloads/toolbox-18.0.0-beta.27.tar.gz
  • checksum was fine
  • 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)

  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.

next: see if the whole thing works!

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?



typing swift run in the Terminal brought some success:

Resolving at 1.0.0-rc.1
Resolving at 1.1.0
Resolving at 2.0.0-rc.1
Resolving at 2.6.2
Resolving at 4.0.0-rc.1
Resolving at 4.0.0-rc.1
Resolving at 4.0.0-rc.3.1
Resolving at 2.0.0
Resolving at 1.4.0
Resolving at 1.0.0
Resolving at 1.2.0
Resolving at 1.9.1
Resolving at 1.1.1
Resolving at 2.14.0
[1349/1349] Linking Run
[ NOTICE ] Server starting on
[ INFO ] GET /
[ INFO ] GET /favicon.ico
[ ERROR ] Abort 404: Not Found

opening resulted in a page displaying "It works!"


For future reference, SPM has this usage doc for providing more details about individual commands

1 Like

Nice! Glad it's working, I wonder how much of that is the removal of OpenSSL/LibreSSL as a dependency! Great that MacPorts is now an option :tada:

I did indeed install openssl using macports before building Vapor 4 … it was listed as dependency in the brew formula.

Yeah the PR to fix that for brew is waiting on APNS fixes, but previously linking to OpenSSL has been broken with MacPorts. Great that it's fixed!

1 Like