Skip to main content

Third-party dependencies

Work in progress

This feature is currently being worked on and is not ready to be used yet.

Dependencies.swift

Learn how to define the contract between the dependency managers (Cocoapods, Carthage and SPM) and Tuist.

Integration status#

  • ✅ Carthage
  • 🚧 Swift Package Manager
  • 🔴 Cocoapods

How to get started#

Step 1: "Dependencies.swift"#

  1. Create Dependencies.swift in your project in Tuist/ directory.
  2. You can read more about Dependencies.swift here.
  3. Run tuist edit to start editing your manifest files.
  4. Add import ProjectDescription on the top of file.
  5. Define your dependencies.

Example of project structure with added Depedencies.swift manifest file:

AwesomeProject    |- App    |- AppTests    |- Tuist        |- Dependencies.swift    |- Project.swift

The snippet below shows an example Dependencies.swift manifest file:

import ProjectDescription
let dependencies = Dependencies(    carthage: [        .github(path: "Alamofire/Alamofire", requirement: .exact("5.0.4"))    ],    swiftPackageManager: nil, // work in progress, pass `nil`    platforms: [.iOS])

Step 2: "tuist dependencies" commands#

  1. Pull dependencies using tuist dependencies fetch command.
  2. You can read more about commands here.
  3. Tuist will save dependencies in /Tuist/Dependencies directory.

The folder structure below shows how Tuist organizes dependencies:

Tuist    |- Dependencies.swift # Manifest    |- Dependencies        |- graph.json        |- Lockfiles            |- Carthage.resolved            |- Package.resolved            |- Podfile.lock # coming soon        |- Carthage # stores content of `Carthage/Build` directory generated by `Carthage`            |- Alamofire.xcframework            |- .Alamofire.version        |- SwiftPackageManager # stores content of `.build/` directory generated by `Swift Package Manager`            |- artifacts            |- checkouts            |- repositories            |- manifest.db            |- workspace-state.json        |- Cocoapods # coming soon            |- RxSwift

If you don't want to check in build artifacts you can update your .gitignore:

# Add this line if you want to avoid checking in a build artifacts from Carthage dependencies.Tuist/Dependencies/Carthage
# Add this line if you want to avoid checking in a build artifacts from Swift Package Manager dependencies.Tuist/Dependencies/SwiftPackageManager
# Add this line if you want to avoid checking in a build artifacts from CocoaPods dependencies.Tuist/Dependencies/Cocoapods

Step 3: Link dependencies#

Link pulled dependencies in your project manifest file.

  1. Run tuist edit to start editing your manifest files.
  2. Open Project.swift.
  3. Define your project with dependencies.

The snippet below shows an example Project.swift manifest file:

import ProjectDescription
let project = Project(    name: "App",    organizationName: "tuist.io",    targets: [        Target(            name: "App",            platform: .iOS,            product: .app,            bundleId: "io.tuist.app",            deploymentTarget: .iOS(targetVersion: "13.0", devices: .iphone),            infoPlist: .default,            sources: ["Targets/App/Sources/**"],            dependencies: [                .xcFramework("Tuist/Dependencies/Carthage/Alamofire.xcframework"),            ]        ),    ])