-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Description
Feature Description
Add Homebrew Formula and tap support to enable easy installation and distribution of the Swift compiler via Homebrew, replacing the need for go install
style distribution.
Motivation
Currently, Swift projects cannot leverage Go's go install
distribution mechanism. Homebrew is the de facto standard for distributing developer tools on macOS, providing:
- Easy installation and updates via
brew install
- Automatic dependency management
- Wide adoption in the Swift/macOS developer community
- Better version management and uninstall capabilities
Proposed Solution
1. Repository Structure
- Add
Makefile
with build, install, uninstall, and clean targets - Create
.github/workflows/release.yml
for automated releases - Set up semantic versioning with git tags
2. Homebrew Formula
- Create
your-compiler.rb
formula with proper Swift build configuration - Use
swift build --configuration release --disable-sandbox
- Include proper installation paths and test verification
- Handle Xcode version dependencies
3. Distribution Strategy
- Phase 1: Personal tap (
homebrew-tap
repository) - Phase 2: Consider submission to official Homebrew core
4. Formula Structure
class YourCompiler < Formula
desc "Swift compiler description"
homepage "https://github.com/yourusername/your-swift-compiler"
url "https://github.com/yourusername/your-swift-compiler/archive/v1.0.0.tar.gz"
sha256 "..."
license "MIT"
head "https://github.com/yourusername/your-swift-compiler.git", branch: "main"
depends_on xcode: ["14.0", :build]
def install
system "make", "install", "PREFIX=#{prefix}"
end
test do
system "#{bin}/your-compiler", "--version"
end
end
Implementation Tasks
- Create Makefile with Swift build automation
- Set up GitHub Actions for release automation
- Create Homebrew formula
- Create personal tap repository
- Test local installation workflow
- Document installation instructions
- Consider bottle (pre-compiled binary) support for faster installs
Alternatives Considered
- Direct binary releases: Less integrated with package managers
- Swift Package Manager: Limited to development dependencies
- Manual installation scripts: Poor user experience and maintenance burden
Additional Context
- Based on successful Swift tools like
swift-format
,swiftgen
,swift-sh
already distributed via Homebrew - Following best practices from NSHipster and Swift community guidelines
- Enables broader adoption by reducing installation friction
References
Metadata
Metadata
Assignees
Labels
No labels