Target
A target of a project that produces a build product.Overview
TheTarget 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
Foreign Build Target
For wrapping non-Xcode build systems (KMP, Rust, CMake, etc.):Standard Target Parameters
.target() Static Method
The name of the target. Also used as the product name if
productName is not specified.The destinations this target supports (e.g.,
.iOS, .macOS, [.iPhone, .iPad]). See the Destinations section below.The type of build product this target will output. See Product Types section below.
The built product name. If
nil, it defaults to the target name.The product bundle identifier (e.g., “com.example.myapp”).
The minimum deployment targets your product will support.
The Info.plist representation. Can be
.default, .file(path:), or .dictionary(_:).The source files of the target. Supports glob patterns. Playgrounds matched by globs are automatically added.
The resource files of the target. Localizable files (
*.lproj) are supported.Folders that should be built as part of the target.
The build phase copy files actions for the target.
The headers for the target (public, private, and project headers).
The entitlements representation. For per-configuration entitlements, keep this as
nil and set CODE_SIGN_ENTITLEMENTS in target settings.The build phase scripts actions for the target.
The target’s dependencies. See Dependencies API for details.
The target’s settings. See Settings API for details.
The Core Data models.
The environment variables used by autogenerated schemes for the target.
The launch arguments used by autogenerated schemes for the target.
The additional files for the target. For project-level additional files, see
Project.additionalFiles.The build rules used for transformation of source files during compilation.
Specifies whether the target can merge dynamic dependencies as part of its binary.
Specifies whether the target can be merged as part of another binary.
The target’s tags associated with on-demand resources.
The target’s metadata.
Foreign Build Parameters
.foreignBuild() Static Method
Wraps non-Xcode build systems like Kotlin Multiplatform (KMP), Rust, or CMake.
A unique name for this foreign build target.
The destinations this target supports.
The shell script that builds the artifact. Runs with
$SRCROOT set to the project directory.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")
The binary artifact produced by the script.Available output types:
.xcframework(path: Path, linking: .static | .dynamic)- An XCFramework output
The target’s metadata.
Product Types
Available product types for theproduct 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 - The parent project containing targets
- Settings - Build settings configuration
- Dependencies - Target dependency types
- Scheme - Build and run schemes