> ## 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.

# Target

> API reference for the Target type in Tuist's ProjectDescription framework

# Target

A target of a project that produces a build product.

## Overview

The `Target` struct represents an individual build target in an Xcode project. Each target can produce a different product type (app, framework, library, etc.) and has its own sources, resources, dependencies, and build settings.

## Standard Target

```swift theme={null}
import ProjectDescription

let target = Target.target(
    name: "MyApp",
    destinations: .iOS,
    product: .app,
    bundleId: "com.example.myapp",
    infoPlist: .default,
    sources: ["Sources/**"],
    resources: ["Resources/**"],
    dependencies: [
        .target(name: "MyFramework"),
        .external(name: "Alamofire")
    ],
    settings: .settings(
        base: ["SWIFT_VERSION": "5.9"],
        configurations: [
            .debug(name: "Debug"),
            .release(name: "Release")
        ]
    )
)
```

## Foreign Build Target

For wrapping non-Xcode build systems (KMP, Rust, CMake, etc.):

```swift theme={null}
let kmpTarget = Target.foreignBuild(
    name: "SharedKMP",
    destinations: .iOS,
    script: """
        eval "$($HOME/.local/bin/mise activate -C $SRCROOT bash --shims)"
        cd $SRCROOT/SharedKMP && gradle assembleSharedKMPReleaseXCFramework
        """,
    inputs: [
        .folder("SharedKMP/src"),
        .file("SharedKMP/build.gradle.kts"),
    ],
    output: .xcframework(
        path: "SharedKMP/build/XCFrameworks/release/SharedKMP.xcframework",
        linking: .dynamic
    )
)
```

## Standard Target Parameters

### `.target()` Static Method

<ParamField path="name" type="String" required>
  The name of the target. Also used as the product name if `productName` is not specified.
</ParamField>

<ParamField path="destinations" type="Destinations" required>
  The destinations this target supports (e.g., `.iOS`, `.macOS`, `[.iPhone, .iPad]`). See the Destinations section below.
</ParamField>

<ParamField path="product" type="Product" required>
  The type of build product this target will output. See Product Types section below.
</ParamField>

<ParamField path="productName" type="String?" default="nil">
  The built product name. If `nil`, it defaults to the target `name`.
</ParamField>

<ParamField path="bundleId" type="String" required>
  The product bundle identifier (e.g., "com.example.myapp").
</ParamField>

<ParamField path="deploymentTargets" type="DeploymentTargets?" default="nil">
  The minimum deployment targets your product will support.
</ParamField>

<ParamField path="infoPlist" type="InfoPlist?" default=".default">
  The Info.plist representation. Can be `.default`, `.file(path:)`, or `.dictionary(_:)`.
</ParamField>

<ParamField path="sources" type="SourceFilesList?" default="nil">
  The source files of the target. Supports glob patterns. Playgrounds matched by globs are automatically added.
</ParamField>

<ParamField path="resources" type="ResourceFileElements?" default="nil">
  The resource files of the target. Localizable files (`*.lproj`) are supported.
</ParamField>

<ParamField path="buildableFolders" type="[BuildableFolder]" default="[]">
  Folders that should be built as part of the target.
</ParamField>

<ParamField path="copyFiles" type="[CopyFilesAction]?" default="nil">
  The build phase copy files actions for the target.
</ParamField>

<ParamField path="headers" type="Headers?" default="nil">
  The headers for the target (public, private, and project headers).
</ParamField>

<ParamField path="entitlements" type="Entitlements?" default="nil">
  The entitlements representation. For per-configuration entitlements, keep this as `nil` and set `CODE_SIGN_ENTITLEMENTS` in target settings.
</ParamField>

<ParamField path="scripts" type="[TargetScript]" default="[]">
  The build phase scripts actions for the target.
</ParamField>

<ParamField path="dependencies" type="[TargetDependency]" default="[]">
  The target's dependencies. See [Dependencies API](/api/dependencies) for details.
</ParamField>

<ParamField path="settings" type="Settings?" default="nil">
  The target's settings. See [Settings API](/api/settings) for details.
</ParamField>

<ParamField path="coreDataModels" type="[CoreDataModel]" default="[]">
  The Core Data models.
</ParamField>

<ParamField path="environmentVariables" type="[String: EnvironmentVariable]" default="[:]">
  The environment variables used by autogenerated schemes for the target.
</ParamField>

<ParamField path="launchArguments" type="[LaunchArgument]" default="[]">
  The launch arguments used by autogenerated schemes for the target.
</ParamField>

<ParamField path="additionalFiles" type="[FileElement]" default="[]">
  The additional files for the target. For project-level additional files, see `Project.additionalFiles`.
</ParamField>

<ParamField path="buildRules" type="[BuildRule]" default="[]">
  The build rules used for transformation of source files during compilation.
</ParamField>

<ParamField path="mergedBinaryType" type="MergedBinaryType" default=".disabled">
  Specifies whether the target can merge dynamic dependencies as part of its binary.
</ParamField>

<ParamField path="mergeable" type="Bool" default="false">
  Specifies whether the target can be merged as part of another binary.
</ParamField>

<ParamField path="onDemandResourcesTags" type="OnDemandResourcesTags?" default="nil">
  The target's tags associated with on-demand resources.
</ParamField>

<ParamField path="metadata" type="TargetMetadata" default=".default">
  The target's metadata.
</ParamField>

## Foreign Build Parameters

### `.foreignBuild()` Static Method

Wraps non-Xcode build systems like Kotlin Multiplatform (KMP), Rust, or CMake.

<ParamField path="name" type="String" required>
  A unique name for this foreign build target.
</ParamField>

<ParamField path="destinations" type="Destinations" required>
  The destinations this target supports.
</ParamField>

<ParamField path="script" type="String" required>
  The shell script that builds the artifact. Runs with `$SRCROOT` set to the project directory.
</ParamField>

<ParamField path="inputs" type="[ForeignBuild.Input]" default="[]">
  Inputs that affect the build output, used for the build phase input file list and content hashing.

  Available input types:

  * `.file(Path)` - A single file whose contents affect the build output
  * `.folder(Path)` - A folder whose contents (recursively) affect the build output
  * `.glob(Path)` - A glob pattern that resolves to files
  * `.script(String)` - A shell script whose stdout produces a cache key component (e.g., `"git rev-parse HEAD"`)
</ParamField>

<ParamField path="output" type="ForeignBuild.Output" required>
  The binary artifact produced by the script.

  Available output types:

  * `.xcframework(path: Path, linking: .static | .dynamic)` - An XCFramework output
</ParamField>

<ParamField path="metadata" type="TargetMetadata" default=".default">
  The target's metadata.
</ParamField>

## Product Types

Available product types for the `product` parameter:

* `.app` - An application
* `.staticLibrary` - A static library
* `.dynamicLibrary` - A dynamic library
* `.framework` - A dynamic framework
* `.staticFramework` - A static framework
* `.unitTests` - A unit tests bundle
* `.uiTests` - A UI tests bundle
* `.bundle` - A custom bundle (currently only iOS resource bundles)
* `.commandLineTool` - A command line tool (macOS only)
* `.appClip` - An App Clip (iOS only)
* `.appExtension` - An application extension
* `.watch2App` - A Watch application (watchOS only)
* `.watch2Extension` - A Watch application extension (watchOS only)
* `.tvTopShelfExtension` - A TV Top Shelf Extension
* `.messagesExtension` - An iMessage extension (iOS only)
* `.stickerPackExtension` - A sticker pack extension
* `.xpc` - An XPC service (macOS only)
* `.systemExtension` - A system extension (macOS only)
* `.extensionKitExtension` - An ExtensionKit extension
* `.macro` - A Swift Macro

## Destinations

Destinations specify which Apple platforms and device types the target supports:

### Platform Convenience Sets

* `.iOS` - `[.iPhone, .iPad, .macWithiPadDesign]`
* `.macOS` - `[.mac]`
* `.tvOS` - `[.appleTv]`
* `.watchOS` - `[.appleWatch]`
* `.visionOS` - `[.appleVision]`

### Individual Destinations

* `.iPhone` - iPhone support
* `.iPad` - iPad support
* `.mac` - Native macOS support
* `.macWithiPadDesign` - macOS using iPad design
* `.macCatalyst` - Mac Catalyst support
* `.appleWatch` - watchOS support
* `.appleTv` - tvOS support
* `.appleVision` - visionOS support
* `.appleVisionWithiPadDesign` - visionOS using iPad design

## Related APIs

* [Project](/api/project) - The parent project containing targets
* [Settings](/api/settings) - Build settings configuration
* [Dependencies](/api/dependencies) - Target dependency types
* [Scheme](/api/scheme) - Build and run schemes
