# 使用 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
- **软件包管理器页面:** <https://formulae.brew.sh/formula/swift-sh>
- **版本:** 2.5.0
- **来源摘要:** Scripting with easy zero-conf dependency imports
- **主页:** <https://github.com/mxcl/swift-sh>
- **仓库:** <https://github.com/mxcl/swift-sh>
- **许可证:** Unlicense
- **源码归档:** <https://github.com/mxcl/swift-sh/archive/refs/tags/2.5.0.tar.gz>
- **已生成:** 2026-08-04T22:13:35+00:00

## 可执行文件

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

## 安装行为

- post-install 钩子: 未定义
- Bottle: 可用 于 arm64_linux, arm64_sequoia, arm64_sonoma, arm64_tahoe, arm64_ventura, sonoma, ventura, x86_64_linux

## 版本和新鲜度

- 页面生成时间: 2026-08-04
- 管理器版本: 2.5.0
- 本地数据: OK
- 上游仓库: https://github.com/mxcl/swift-sh
- 检测到的最新版本: 2.5.0 (当前)
- 信息: No package-manager update timestamp was available.
## 项目历史与用法

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

## 源数据库详情

- **Source Database:** Homebrew formula API
- **Tap:** homebrew/core
- **Full Name:** swift-sh
- **Version Scheme:** 0
- **Revision:** 1
- **Head Version:** HEAD
- **Requirements:** xcode
- **Bottle Stable Root URL:** <https://ghcr.io/v2/homebrew/core>
- **Deprecated:** no
- **Disabled:** no
- **Keg Only:** no
- **URL Keys:** head, stable


## 相关链接

- [Source-control packages](https://pkg.so/zh-hans/source-control-tools/) - Belongs to a source-control command family.
- [Terminal utility packages](https://pkg.so/zh-hans/terminal-utilities/) - Matched terminal and command-line workflow metadata.
- [Text processing packages](https://pkg.so/zh-hans/text-processing-tools/) - Matched text, document, or structured-data processing metadata.
- [Developer build packages](https://pkg.so/zh-hans/developer-build-tools/) - Matched build, compiler, generator, or developer workflow metadata.
- [swift-outdated](https://pkg.so/zh-hans/brew/swift-outdated/) - Shares pkgdb curated category or tags: cli, dependency-management, developer-tools, swift, swift-package-manager.
- [rust-script](https://pkg.so/zh-hans/brew/rust-script/) - Shares pkgdb curated category or tags: cli, developer-tools, scripting.
- [attempt-cli](https://pkg.so/zh-hans/brew/attempt-cli/) - Shares pkgdb curated category or tags: cli, developer-tools, scripting.
- [scriptisto](https://pkg.so/zh-hans/brew/scriptisto/) - Shares pkgdb curated category or tags: cli, developer-tools, scripting.
- [objc-run](https://pkg.so/zh-hans/brew/objc-run/) - Shares pkgdb curated category or tags: cli, developer-tools, scripting.
- [xcbeautify](https://pkg.so/zh-hans/brew/xcbeautify/) - Shares pkgdb curated category or tags: cli, developer-tools, swift.
- [swiftlint](https://pkg.so/zh-hans/brew/swiftlint/) - Shares pkgdb curated category or tags: cli, developer-tools, swift.
- [maven](https://pkg.so/zh-hans/brew/maven/) - Shares pkgdb curated category or tags: cli, dependency-management, developer-tools.
- [carthage](https://pkg.so/zh-hans/brew/carthage/) - Local package facts share a topical domain. Shared terms: cli, dependency, dependency-management, developer, developer-tools.
- [swift-format](https://pkg.so/zh-hans/brew/swift-format/) - Package names and metadata indicate a similar tool family. Shared terms: cli, developer, developer-tools, swift.

## 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
- package-page enrichment
- curated package history
- package version freshness
- pkgdb category and tag curation
- package relationship graph
- cross-ecosystem install command graph
