SwiftPM’s lack of an easy install feature has long been an issue of mine and for other people too. As the linked forums thread suggests, to accomplish this for a general audience requires some careful thinking: adding to /usr/local/bin is not always the best solution for every user.
Still, it’s a feature whose absence is notable. To fill the gap, I’ve discovered Yonas Kolb’s mint. Thank you to Leo Dion, who introduced this to me. It is ridiculously simple to use. Could it get easier than
mint install erica/now? Admittedly my github id is short and so is my project name, but I think my point stands…
Yesterday, I hastily added a SwiftPM project to
remind so it too could be installed via mint. Suddenly, adding the project specification is no longer an afterthought but a driving feature. It’s made SwiftPM support far more valuable to me for executables.
Make sure you name your primary file
main.swift, your product to
.executable, and if you’re developing in Xcode, override your
path to point to the Xcode-project-style folder for the source files, usually the same name as the project itself. I mention this because Xcode by default (File > New > Swift Package) builds library projects, not executable ones. At the command-line use
swift package init --type executable.
// swift-tools-version:5.2 // The swift-tools-version declares the minimum version of Swift required to build this package. import PackageDescription let package = Package( name: "remind", platforms: [ .macOS(.v10_12) ], products: [ .executable( name: "remind", targets: ["remind"]), ], dependencies: [ .package(url: "https://github.com/apple/swift-argument-parser", from: "0.0.6"), ], targets: [ .target( name: "remind", dependencies: [.product(name: "ArgumentParser", package: "swift-argument-parser")], path: "remind/" ), ], swiftLanguageVersions: [ .v5 ] )
mint itself, you can build it or install it via HomeBrew:
brew install mint.
If you have any suggestions on how I can improve my SwiftPM work, better integrate tagging, or any other tips, please let me know. Thanks!