# 使用 Homebrew 安装 swift-sh

查看 swift-sh 的安装路径、可执行文件、元数据以及面向 AI 代理工作流的安全说明。

## 安装

```sh
sudo av install brew:swift-sh
```

其他安装命令:

### macOS

- Homebrew (100%):

```sh
brew install swift-sh
```

  证据: local Homebrew formula metadata

## 软件包事实

- **软件包键:** brew:swift-sh
- **软件包管理器:** Homebrew
- **版本:** 2.5.0
- **来源摘要:** Scripting with easy zero-conf dependency imports
- **主页:** <https://github.com/mxcl/swift-sh>
- **仓库:** <https://github.com/mxcl/swift-sh>
- **已生成:** 2026-08-03T19:37:03+00:00

## 可执行文件

- swift-sh (别名)
- swift-sh-edit (别名)

## 安装行为

- Bottle: 不可用

## 版本和新鲜度

- 页面生成时间: 2026-08-03
- 管理器版本: 2.5.0
## 项目历史与用法

swift-sh is a Swift scripting tool that lets single-file Swift scripts declare third-party SwiftPM dependencies inline on import statements, then builds and runs those scripts through Swift Package Manager.

### 项目历史

The public repository was created in 2019. The README frames the project as a response to the friction of turning a quick Swift script into a full Swift package just to use dependencies, offering a shebang-based workflow instead.

### 采用历史

The README documents Homebrew installation and explains that the installed `swift-sh` executable is discoverable through Swift's subcommand mechanism as `swift sh`. Homebrew lists bottles for macOS and Linux, matching the README's stated support for Linux and Mac.

### 使用方式

A script starts with `#!/usr/bin/swift sh` and declares dependencies in comments after import lines. swift-sh reads those comments, creates a cached SwiftPM package, builds it, and runs it with `swift run`; it also documents `swift sh edit` for Xcode editing and `swift sh eject` for converting a script into a package.

### 为什么软件包爱好者会关心

swift-sh matters in package-manager culture because it narrows the gap between scripting and package-based dependency resolution. It makes SwiftPM usable for disposable or operational scripts without asking users to keep a full package directory around from the start.

### 时间线

- 2019: Public GitHub repository created.
- Current docs: Installed with Homebrew or built manually with `swift build`.
- Current docs: v2 requires Swift 5.1 and uses the active Swift toolchain to generate the temporary package manifest.

### Related projects

- The README lists Beak and Marathon as alternatives and builds on Swift Package Manager, Xcode, and Swift's subcommand dispatch behavior.

### 来源

- <https://api.github.com/repos/mxcl/swift-sh>
- <https://formulae.brew.sh/api/formula/swift-sh.json>
- <https://github.com/mxcl/swift-sh#readme>


## 安全说明

narrow executable package without higher-risk signals.

- **Geiger 风险:** 绿色 / 低
- narrow executable package without higher-risk signals


## Combined YAML source

View the package source record on GitHub. [combined/swift-sh.yml](https://github.com/mxcl/pkgdb/blob/main/combined/swift-sh.yml)


## 来源

- pkg.so package database
- Geiger risk classifier
- curated package history
- pkgdb category and tag curation
- cross-ecosystem install command graph
