📦 Carthage for Swift: Decentralized Dependency Manager
\n\nCarthage is a decentralized dependency manager for the Apple ecosystem (iOS, macOS, tvOS, watchOS). Unlike CocoaPods, Carthage does not modify your project automatically — it builds frameworks, and you connect them to Xcode yourself. This gives you full control over the build process and minimal "magic".
\n\nThe library uses Carthage (the name matches the tool) and works through a Cartfile — a declarative file that lists dependencies. Carthage clones repositories, builds them (using xcodebuild), and places the resulting .framework files in the Carthage/Build folder. You manually add them to your project.
Why use Carthage? If you value transparency, want to avoid version conflicts, and dislike tools that automatically modify your project. It's ideal for teams where each member decides how to connect dependencies, and for projects with strict build security requirements.
\n\n\n\n
1. Installing Carthage
\n\nCarthage can be installed via Homebrew (recommended) or by downloading the .pkg from GitHub.
\n\n# Installation via Homebrew\nbrew install carthage\n\n# Check version\ncarthage version\n\nIf Homebrew is not installed, install it first: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Linux or Windows are not officially supported by Carthage (macOS only).
\n\n\n\n
2. Quick Start — Minimal Working Example
\n\nCreate a new Xcode project (e.g., Single View App). Then, in the project root, create a file named Cartfile (no extension) and add a dependency:
\n\n# Cartfile\ngithub "Alamofire/Alamofire" ~> 5.8\n\nNow run the command in the terminal (from the project folder):
\n\ncarthage update --platform iOS\n\nAfter completion, Alamofire.framework will appear in the Carthage/Build/iOS folder. Open Xcode, drag this .framework into the Frameworks, Libraries, and Embedded Content section of your target. Select "Embed & Sign".
Now you can import the library:
\n\nimport Alamofire\n\n// Minimal request\nAF.request("https://api.github.com/users/defunkt").response { response in\n debugPrint(response)\n}\n\nDone! You have just connected a dependency via Carthage.
\n\n\n\n
3. Main Methods and Functions of Carthage
\n\nBelow are the key commands and capabilities of Carthage. Most of them are invoked from the terminal.
\n\n🔹 1. carthage update
\n Signature carthage update [--platform PLATFORM] [--configuration CONFIG] [--no-build] [--use-xcframeworks]
What it does: Downloads and builds all dependencies from Cartfile.resolved (or updates to the latest versions if Cartfile.resolved is absent). Creates the Carthage/Build folder.
\n# Update only for iOS, using xcframeworks\ncarthage update --platform iOS --use-xcframeworks\n🔹 2. carthage bootstrap
\n Signature carthage bootstrap [--platform PLATFORM] [--configuration CONFIG] [--use-xcframeworks]
What it does: Builds dependencies using the existing Cartfile.resolved (without updating versions). Ideal for CI/CD — guarantees reproducible builds.
\n# Rebuild everything as is