Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing Vapor on macOS without needing Homebrew

Tags:

swift

vapor

I am trying to get a Swift Vapor project started. Following the guide here, it seems that Homebrew is the only option. I already have MacPorts and prefer it in many ways to Homebrew. Unfortunately there is no port for Vapor, so I went for the SPM installation that Vapor people describe here. I had previous success with Kitura, so I thought why not with Vapor. Well, when you go and build your project, you get

$ swift build

[... build stuff ...]

note: you may be able to install ctls using your system-packager:

    brew install ctls

[... more build stuff ...]

<module-includes>:1:9: note: in file included from <module-includes>:1:
#import "shim.h"
    ^
[... more like that ...]

  /Users/morpheu5/web/vizex/api/.build/checkouts/crypto.git-7980259129511365902/Sources/Crypto/Cipher/Cipher+Method.swift:1:8: error: could not build Objective-C module 'CTLS'
import CTLS
    ^
<unknown>:0: error: build had 1 command failures
error: exit(1):/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-build-tool -f /Users/morpheu5/web/vizex/api/.build/debug.yaml

Apparently you really need this ctls package, and the only way of getting it appears to be through Homebrew/Tap.

I really don't want or need Homebrew, so how do I get to the bottom of this? I'd really like to give Vapor a try.

like image 907
Morpheu5 Avatar asked Aug 23 '17 10:08

Morpheu5


People also ask

How do I install vapor on my Mac?

On macOS, simply install Xcode from the Mac App Store. On Linux, download it from https://www.swift.org as install as described below. Vapor 4 requires Swift 5.2, both in Xcode and from the command line. Xcode 11.4 and 11.5 both provide Swift 5.2.


1 Answers

Obligatory 1: installing Homebrew is the easiest way. If you then decide you don't want Homebrew, it uninstalls quite neatly.

Obligatory 2: using a Linux VM is the second easiest way.

But to answer your question and manually install CTLS:

  1. Make sure you have the libraries for LibreSSL or OpenSSL installed (using MacPorts, presumably)

  2. Download the latest release of CTLS.

  3. From the release archive, rename macos.pc to ctls.pc and then edit it using a text editor. Change the paths to point to your LibreSSL/OpenSSL installation.

  4. Move the edited ctls.pc into your $PKG_CONFIG_PATH.

I have tested this and it works for me, with the caveat that I installed LibreSSL using Homebrew so I don't know where MacPorts will put it.

like image 141
tobygriffin Avatar answered Oct 09 '22 10:10

tobygriffin