Convert Figma logo to code with AI

yonaskolb logoMint

A package manager that installs and runs executable Swift packages

2,278
122
2,278
58

Top Related Projects

14,559

The Cocoa Dependency Manager.

14,950

A simple, decentralized dependency manager for Cocoa

The Package Manager for the Swift Programming Language

4,503

Tuist's CLI

Swift Version Manager

18,578

A tool to enforce Swift style and conventions.

Quick Overview

Mint is a package manager for Swift command-line tools. It simplifies the process of installing and managing Swift packages globally, making it easier for developers to use and distribute Swift executables.

Pros

  • Easy installation and management of Swift packages
  • Supports versioning and dependency resolution
  • Integrates well with existing Swift package ecosystem
  • Cross-platform support (macOS and Linux)

Cons

  • Limited to command-line tools and executables
  • Requires Xcode or Swift toolchain to be installed
  • May conflict with other package managers (e.g., Homebrew) if not managed carefully
  • Relatively new project, still evolving and gaining adoption

Code Examples

Installing a package:

mint install realm/SwiftLint

Running a command from an installed package:

mint run SwiftLint

Installing a specific version of a package:

mint install yonaskolb/XcodeGen@2.18.0

Getting Started

  1. Install Mint:

    brew install mint
    
  2. Install a Swift package:

    mint install vapor/vapor-cli
    
  3. Run a command from the installed package:

    mint run vapor
    
  4. List installed packages:

    mint list
    
  5. Update Mint:

    mint update
    

For more advanced usage and options, refer to the official Mint documentation on GitHub.

Competitor Comparisons

14,559

The Cocoa Dependency Manager.

Pros of CocoaPods

  • Widely adopted and well-established in the iOS development community
  • Supports a vast library of third-party dependencies
  • Integrates seamlessly with Xcode projects

Cons of CocoaPods

  • Can slow down project build times, especially for large projects
  • Requires maintenance of a separate Podfile and occasional pod updates
  • May introduce complexities in version management and conflicts

Code Comparison

CocoaPods (Podfile):

platform :ios, '13.0'
use_frameworks!

target 'MyApp' do
  pod 'Alamofire', '~> 5.0'
end

Mint (Package.swift):

// swift-tools-version:5.3
import PackageDescription

let package = Package(
    name: "MyApp",
    dependencies: [
        .package(url: "https://github.com/Alamofire/Alamofire.git", .upToNextMajor(from: "5.0.0"))
    ]
)

While CocoaPods uses a separate Podfile to manage dependencies, Mint leverages Swift Package Manager's Package.swift file for dependency management. CocoaPods offers a more straightforward syntax for specifying dependencies, while Mint provides tighter integration with Swift's native package management system.

14,950

A simple, decentralized dependency manager for Cocoa

Pros of Carthage

  • Supports multiple platforms (iOS, macOS, tvOS, watchOS)
  • Builds frameworks directly from source, allowing for more control
  • Integrates well with Xcode and doesn't modify project structure

Cons of Carthage

  • Slower build times compared to Mint
  • Requires manual framework linking in Xcode
  • More complex setup and maintenance

Code Comparison

Carthage:

github "Alamofire/Alamofire" ~> 5.0
github "SwiftyJSON/SwiftyJSON" ~> 5.0

Mint:

let package = Package(
    dependencies: [
        .package(url: "https://github.com/Alamofire/Alamofire.git", from: "5.0.0"),
        .package(url: "https://github.com/SwiftyJSON/SwiftyJSON.git", from: "5.0.0")
    ]
)

Key Differences

  • Carthage uses a Cartfile for dependency management, while Mint uses Swift Package Manager
  • Carthage builds frameworks, whereas Mint installs and runs Swift command-line tools
  • Mint focuses on simplicity and ease of use, while Carthage offers more flexibility and control

Use Cases

  • Carthage: Larger projects with complex dependencies across multiple platforms
  • Mint: Simpler projects or those primarily focused on command-line tools and scripts

The Package Manager for the Swift Programming Language

Pros of Swift Package Manager

  • Official Apple-supported tool integrated into Xcode
  • Broader ecosystem support and compatibility with Swift projects
  • Handles dependencies for entire projects, not just command-line tools

Cons of Swift Package Manager

  • More complex setup and configuration required
  • Slower build times for simple command-line tools
  • Less focused on managing and running executable packages

Code Comparison

Swift Package Manager (Package.swift):

// swift-tools-version:5.5
import PackageDescription

let package = Package(
    name: "MyPackage",
    dependencies: [
        .package(url: "https://github.com/example/dependency.git", from: "1.0.0"),
    ],
    targets: [
        .executableTarget(name: "MyExecutable", dependencies: ["Dependency"]),
    ]
)

Mint (Mintfile):

yonaskolb/xcodegen@2.25.0
realm/SwiftLint@0.45.1

Swift Package Manager is a comprehensive dependency management solution for Swift projects, while Mint focuses on simplifying the installation and running of Swift command-line tools. SPM offers more flexibility and integration with larger projects, but Mint provides a more streamlined experience for managing executable packages.

4,503

Tuist's CLI

Pros of Tuist

  • Offers a more comprehensive project generation and management solution
  • Provides advanced caching mechanisms for faster builds
  • Supports custom project description manifests for greater flexibility

Cons of Tuist

  • Steeper learning curve due to its more complex feature set
  • Requires more setup and configuration compared to Mint's simplicity
  • May be overkill for smaller projects or teams

Code Comparison

Mint (Package definition):

import PackageDescription

let package = Package(
    name: "MyTool",
    dependencies: [
        .package(url: "https://github.com/Alamofire/Alamofire.git", from: "5.0.0"),
    ],
    targets: [
        .target(name: "MyTool", dependencies: ["Alamofire"]),
    ]
)

Tuist (Project manifest):

import ProjectDescription

let project = Project(
    name: "MyApp",
    targets: [
        Target(
            name: "MyApp",
            platform: .iOS,
            product: .app,
            bundleId: "com.example.MyApp",
            infoPlist: "Info.plist",
            sources: ["Sources/**"],
            dependencies: [
                .package(product: "Alamofire")
            ]
        )
    ]
)

Swift Version Manager

Pros of swiftenv

  • Focuses specifically on Swift version management
  • Supports automatic version switching based on .swift-version files
  • Integrates well with system-wide Swift installations

Cons of swiftenv

  • Limited to Swift version management, not a general-purpose package manager
  • Requires manual installation of Swift versions
  • Less active development and community support compared to Mint

Code Comparison

swiftenv:

swiftenv install 5.3
swiftenv global 5.3
swiftenv local 5.2

Mint:

mint install Alamofire
mint run Alamofire
mint bootstrap

Summary

swiftenv is a specialized tool for managing Swift versions, offering automatic version switching and system-wide integration. However, it's limited to version management and requires manual Swift installations. Mint, on the other hand, is a more versatile package manager for Swift command-line tools, with easier installation and running of packages. Mint has a more active development community but lacks the specific version management features of swiftenv. The choice between the two depends on whether you need focused Swift version management (swiftenv) or a more general-purpose Swift package manager (Mint).

18,578

A tool to enforce Swift style and conventions.

Pros of SwiftLint

  • Specifically designed for Swift code linting, offering a wide range of built-in rules
  • Highly configurable with the ability to enable/disable rules and set custom thresholds
  • Integrates well with Xcode and other development tools

Cons of SwiftLint

  • Limited to Swift linting, while Mint can manage and run various Swift command-line tools
  • Requires more setup and configuration compared to Mint's simpler approach
  • Can be resource-intensive for large projects, potentially slowing down the build process

Code Comparison

SwiftLint configuration example:

disabled_rules:
  - trailing_whitespace
opt_in_rules:
  - empty_count
  - missing_docs
line_length:
  warning: 120
  error: 200

Mint usage example:

import Mint

Mint.install("realm/SwiftLint")
Mint.run("swiftlint", arguments: ["lint", "--path", "Sources"])

While SwiftLint focuses on linting Swift code with extensive rule configurations, Mint serves as a package manager and runner for Swift command-line tools, offering a broader scope of functionality beyond just linting.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Mint 🌱

Swift Versions Platforms Git Version License

A package manager that installs and runs Swift command line tool packages.

mint run realm/SwiftLint@0.40.3

This would install and run SwiftLint version 0.40.3

Mint is designed to be used with Swift command line tools that build with the Swift Package Manager. It makes installing, running and distributing these tools much easier.

  • ✅ easily run a specific version of a package
  • ✅ link a package globally
  • ✅ builds are cached by version
  • ✅ use different versions of a package side by side
  • ✅ easily run the latest version of a package
  • ✅ distribute your own packages without recipes and formulas
  • ✅ specify a list of versioned packages in a Mintfile for easy use

Homebrew is a popular method of distributing Swift executables, but that requires creating a formula and then maintaining that formula. Running specific versions of homebrew installations can also be tricky as only one global version is installed at any one time. Mint installs your package via SPM and lets you run multiple versions of that package, which are installed and cached in a central place.

If your Swift executable package builds with SPM, then it can be run with Mint! See Support for details.

Why is it called Mint?

Swift Package Manager Tools -> SPMT -> Spearmint -> Mint! 🌱😄

Mint: a place where something is produced or manufactured

Installing

Make sure Xcode 10.2 is installed first.

Homebrew

brew install mint

Make

git clone https://github.com/yonaskolb/Mint.git
cd Mint
make

Using Mint itself!

Install
git clone https://github.com/yonaskolb/Mint.git
cd Mint
swift run mint install yonaskolb/mint
Update
mint install yonaskolb/mint

Swift Package Manager

Use CLI

git clone https://github.com/yonaskolb/Mint.git
cd Mint
swift run mint

Use as dependency

Add the following to your Package.swift file's dependencies:

.package(url: "https://github.com/yonaskolb/Mint.git", from: "0.15.0"),

And then import wherever needed: import MintKit

Road to 1.0

Until 1.0 is reached, minor versions will be breaking.

Usage

Run mint help to see usage instructions.

  • install: Installs a package, so it can be run with run later, and also links that version globally
  • run: Runs a package. This will install it first if it isn't already installed, though won't link it globally. It's useful for running a certain version.
  • list: Lists all currently installed packages and versions.
  • which: Print the path to an installed package executable.
  • uninstall: Uninstalls a package by name.
  • bootstrap: Installs all the packages in your Mintfile, by default, without linking them globally

Package reference

run and install commands require a package reference parameter. This can be a shorthand for a github repo (mint install realm/SwiftLint) or a fully qualified git path (mint install https://github.com/realm/SwiftLint.git). In the case of run you can also just pass the name of the repo if it is already installed (run swiftlint) or in the Mintfile. An optional version can be specified by appending @version, otherwise the newest tag or master will be used. Note that if you don't specify a version, the current tags must be loaded remotely each time.

Examples

$ mint run yonaskolb/XcodeGen@2.18.0 # run the only executable
$ mint run yonaskolb/XcodeGen@2.18.0 --spec spec.yml # pass some arguments
$ mint run yonaskolb/XcodeGen@2.18.0 xcodegen --spec spec.yml # specify a specific executable
$ mint run --executable xcodegen yonaskolb/XcodeGen@2.18.0 --spec spec.yml # specify a specific executable in case the first argument is the same name as the executable
$ mint install yonaskolb/XcodeGen@2.18.0 --no-link # installs a certain version but doesn't link it globally
$ mint install yonaskolb/XcodeGen # install newest tag
$ mint install yonaskolb/XcodeGen@master --force #reinstall the master branch
$ mint run yonaskolb/XcodeGen@2.18.0 # run 2.18.0
$ mint run XcodeGen # use newest tag and find XcodeGen in installed packages

Linking

By default Mint symlinks your installs into ~/.mint/bin on mint install, unless --no-link is passed. This means a package will be accessible from anywhere, and you don't have to prepend commands with mint run package, as long as you add ~/.mint/bin to your $PATH. Note that only one linked version can be used at a time. If you need to run a specific older version use mint run.

Mintfile

A Mintfile can specify a list of versioned packages. It makes installing and running these packages easy, as the specific repos and versions are centralized.

Simply place this file in the directory you're running Mint in. The format of the Mintfile is simply a list of packages in the same form as the usual package parameter:

yonaskolb/xcodegen@2.18.0
yonaskolb/genesis@0.4.0

Then you can simply run a package using:

mint run xcodegen

Note that mint will find the version declared in your Mintfile and run that version, even if you have multiple versions installed.

Or install all the packages (without linking them globally) in one go with:

mint bootstrap

If you prefer to link them globally, do such with:

mint bootstrap --link

Advanced

  • You can use --silent in mint run to silence any output from mint itself. Useful if forwarding output somewhere else.
  • You can set MINT_PATH and MINT_LINK_PATH envs to configure where mint caches builds, and where it symlinks global installs. These default to ~/.mint and ~/.mint/bin respectively
  • You can use mint install --force to reinstall a package even if it's already installed. This shouldn't be required unless you are pointing at a branch and want to update it.

Linux

Mint works on Linux but has some limitations:

  • linux doesn't support building with a statically linked version of Swift. This means when a new version of swift comes out the old installs won't work on linux.
  • Linux is case sensitive so you must specify the correct case for repo urls as well as executables.

Support

If your Swift command line tool builds with the Swift Package Manager than it will automatically install and run with mint!

Make sure you have defined an executable product type in the products list within your Package.swift.

let package = Package(
    name: "Foo",
    products: [
        .executable(name: "foo", targets: ["Foo"]),
    ],
    targets: [
      .target(name: "Foo"),
      ...
    ]
)

You can then add this to the Installing section in your readme:

### [Mint](https://github.com/yonaskolb/mint)
```
mint run github_name/repo_name
```

Resources

Since Swift 5.3 resources are now built into the Swift Package manager, so if you're targetting that version or above the Package.resources file is no longer necessary https://github.com/apple/swift-evolution/blob/master/proposals/0271-package-manager-resources.md

The Swift Package Manager doesn't yet have a way of specifying resources directories. If your tool requires access to resources from the repo you require a custom Package.resources file. This is a plain text file that lists the resources directories on different lines:

MyFiles
MyOtherFiles

If this file is found in you repo, then all those directories will be copied into the same path as the executable.

A list of popular Mint compatible packages 🌱

Feel free to add your own!