Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/tuist/tuist/llms.txt

Use this file to discover all available pages before exploring further.

Dependencies

Target dependency types that define how targets depend on other code.

Overview

The TargetDependency enum defines all possible types of dependencies that a target can have, including dependencies on other targets, external packages, system frameworks, and prebuilt binaries.

Dependency Types

Target Dependency

Depend on another target within the same project.
.target(name: "MyFramework")
.target(name: "MyFramework", status: .optional)
.target(name: "MyFramework", condition: .when([.ios]))
name
String
required
Name of the target to depend on.
status
LinkingStatus
default:".required"
The dependency status. Use .optional for weak linking, .required for strong linking, or .none to skip linking.
condition
PlatformCondition?
default:"nil"
Condition under which to use this dependency. nil means always use it.

Macro Dependency

Depend on a Swift macro target within the same project.
.macro(name: "MyMacro")
name
String
required
Name of the macro target to depend on.

Project Dependency

Depend on a target within another project.
.project(target: "Framework", path: "../Framework")
.project(target: "Framework", path: "../Framework", status: .optional)
target
String
required
Name of the target to depend on.
path
Path
required
Relative path to the other project directory.
status
LinkingStatus
default:".required"
The dependency status (optional dependencies are weakly linked).
condition
PlatformCondition?
default:"nil"
Condition under which to use this dependency.

External Dependency

Depend on an external dependency imported through Package.swift. This is the recommended approach.
.external(name: "Alamofire")
.external(name: "Alamofire", condition: .when([.ios]))
name
String
required
Name of the external dependency as declared in Package.swift.
condition
PlatformCondition?
default:"nil"
Condition under which to use this dependency.

Package Dependency

Depend on a Swift Package Manager product using Xcode native integration. It’s recommended to use .external instead. For more info, check the external dependencies documentation.
.package(product: "Alamofire")
.package(product: "MyMacro", type: .macro)
.package(product: "MyPlugin", type: .plugin)
product
String
required
The name of the output product (e.g., “RxSwift”).
type
PackageType
default:".runtime"
The type of package being integrated:
  • .runtime - Standard package linked at runtime
  • .runtimeEmbedded - Package embedded in the product at runtime
  • .plugin - Build system plugin loaded at compile-time
  • .macro - Swift Macro package
condition
PlatformCondition?
default:"nil"
Condition under which to use this dependency.

Framework Dependency

Depend on a prebuilt framework.
.framework(path: "Frameworks/MyFramework.framework")
.framework(path: "Frameworks/MyFramework.framework", status: .optional)
path
Path
required
Relative path to the prebuilt framework.
status
LinkingStatus
default:".required"
The dependency status (optional dependencies are weakly linked).
condition
PlatformCondition?
default:"nil"
Condition under which to use this dependency.

XCFramework Dependency

Depend on an XCFramework.
.xcframework(path: "Frameworks/MyFramework.xcframework")
.xcframework(
    path: "Frameworks/MyFramework.xcframework",
    expectedSignature: .signedWithAppleCertificate(
        teamIdentifier: "ABCDE12345",
        teamName: "My Team"
    ),
    status: .required
)
path
Path
required
Relative path to the xcframework.
expectedSignature
XCFrameworkSignature?
default:"nil"
The expected signature if the xcframework is signed. Used for verifying integrity.
  • .unsigned - The XCFramework is not signed
  • .signedWithAppleCertificate(teamIdentifier:teamName:) - Signed with Apple Development certificate
  • .selfSigned(fingerprint:) - Signed with self-issued code signing identity
status
LinkingStatus
default:".required"
The dependency status (optional dependencies are weakly linked).
condition
PlatformCondition?
default:"nil"
Condition under which to use this dependency.

Library Dependency

Depend on a prebuilt static library.
.library(
    path: "Libraries/libMyLibrary.a",
    publicHeaders: "Libraries/include",
    swiftModuleMap: "Libraries/MyLibrary.swiftmodule"
)
path
Path
required
Relative path to the prebuilt library.
publicHeaders
Path
required
Relative path to the library’s public headers directory.
swiftModuleMap
Path?
required
Relative path to the library’s Swift module map file.
condition
PlatformCondition?
default:"nil"
Condition under which to use this dependency.

SDK Dependency

Depend on a system library or framework.
.sdk(name: "UIKit", type: .framework)
.sdk(name: "c++", type: .library)
.sdk(name: "ARKit", type: .framework, status: .optional)
name
String
required
Name of the system library or framework without extension (e.g., “ARKit”, “c++”).
type
SDKType
required
The dependency type:
  • .framework - Framework SDK
  • .library - Library SDK (in usr/lib)
  • .swiftLibrary - Swift library SDK (in usr/lib/swift)
status
LinkingStatus
default:".required"
The dependency status (optional dependencies are weakly linked).
condition
PlatformCondition?
default:"nil"
Condition under which to use this dependency.

XCTest Dependency

Depend on XCTest framework.
.xctest
No parameters required.

LinkingStatus

Controls how a dependency is linked:
  • .required - Required dependency (strong linking)
  • .optional - Optional dependency (weak linking)
  • .none - Skip linking entirely

PlatformCondition

Allows conditional dependencies based on platform:
// Only link on iOS
.target(name: "iOSOnlyFramework", condition: .when([.ios]))

// Link on iOS and tvOS
.framework(path: "SharedFramework.framework", condition: .when([.ios, .tvos]))

// Link on all platforms except watchOS
.external(name: "Alamofire", condition: .when([.ios, .macos, .tvos, .visionos]))

Usage Examples

Basic Target with Dependencies

let target = Target.target(
    name: "MyApp",
    destinations: .iOS,
    product: .app,
    bundleId: "com.example.myapp",
    dependencies: [
        // Internal target
        .target(name: "MyFramework"),
        
        // External package
        .external(name: "Alamofire"),
        
        // System framework
        .sdk(name: "UIKit", type: .framework),
        
        // Optional system framework
        .sdk(name: "StoreKit", type: .framework, status: .optional)
    ]
)

Cross-Project Dependencies

let target = Target.target(
    name: "MyApp",
    destinations: .iOS,
    product: .app,
    bundleId: "com.example.myapp",
    dependencies: [
        .project(target: "SharedUI", path: "../SharedUI"),
        .project(target: "SharedLogic", path: "../SharedLogic")
    ]
)

Platform-Specific Dependencies

let target = Target.target(
    name: "MultiplatformApp",
    destinations: [.iPhone, .iPad, .mac],
    product: .app,
    bundleId: "com.example.app",
    dependencies: [
        // Always included
        .target(name: "SharedCore"),
        
        // iOS only
        .target(name: "iOSFeatures", condition: .when([.ios])),
        
        // macOS only
        .target(name: "macOSFeatures", condition: .when([.macos])),
        
        // iOS system framework
        .sdk(name: "UIKit", type: .framework, condition: .when([.ios])),
        
        // macOS system framework
        .sdk(name: "AppKit", type: .framework, condition: .when([.macos]))
    ]
)

Swift Macro Dependencies

let target = Target.target(
    name: "MyApp",
    destinations: .iOS,
    product: .app,
    bundleId: "com.example.myapp",
    dependencies: [
        // Internal macro
        .macro(name: "MyMacros"),
        
        // External macro
        .package(product: "SwiftMacrosPackage", type: .macro)
    ]
)
  • Target - Uses dependencies
  • Project - Contains targets with dependencies
  • Settings - Can affect dependency linking

Build docs developers (and LLMs) love