iTranslated by AI
The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
📦
[Swift] Installing Executables Created with Swift Package Manager
Previously, installing Swift executables required third-party package managers like Mint, but starting from Swift Package Manager 5.10, an experimental installation feature has been added.
swift --version
swift-driver version: 1.90.11.1 Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4)
Target: arm64-apple-macosx14.0
Binaries are placed in ~/.swiftpm/bin, so add the following PATH to your .zshrc or similar.
.zshrc
export PATH=$HOME/.swiftpm/bin:$PATH
Creating and Installing Hello, World
Creating a project
$ mkdir example-swift-hello-world
$ cd example-swift-hello-world
$ swift package init --type executable
Installation
$ swift package experimental-install
Execution
$ example-swift-hello-world
Hello, world!
Uninstallation
$ swift package experimental-uninstall example-swift-hello-world
Discussion