无需 Homebrew 即可在 macOS 上安装 Vapor

Installing Vapor on macOS without needing Homebrew

我正在尝试启动一个 Swift Vapor 项目。按照指南 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。我之前使用 Kitura 取得过成功,所以我想为什么不使用 Vapor。好吧,当你去构建你的项目时,你会得到

$ 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

显然您确实需要这个 ctls 包,而获得它的唯一方法似乎是通过 Homebrew/Tap。

我真的不想或不需要 Homebrew,那么我该如何深入了解呢?我真的很想试试 Vapor。

必修课1:安装Homebrew是最简单的方法。如果您随后决定不想要 Homebrew,它会非常干净地卸载。

强制性 2:使用 Linux 虚拟机是第二种最简单的方法。

但是要回答你的问题并手动安装CTLS:

  1. 确保安装了 LibreSSLOpenSSL 的库(大概使用 MacPorts)

  2. 下载 CTLS 的最新 release

  3. 从发布存档中,将 macos.pc 重命名为 ctls.pc,然后使用文本编辑器对其进行编辑。更改路径以指向您的 LibreSSL/OpenSSL 安装。

  4. 将已编辑的 ctls.pc 移动到您的 $PKG_CONFIG_PATH

我已经测试过它,它对我有用,但我使用 Homebrew 安装 LibreSSL 的警告,所以我不知道 MacPorts 会把它放在哪里。