---
title: "Swift Package Manager (SPM)"
description: "Integrate Sentry into your Xcode project using Swift Package Manager (SPM)."
url: https://docs.sentry.io/platforms/apple/install/swift-package-manager/
---

# Swift Package Manager (SPM) | Sentry for Apple

To integrate Sentry into your Xcode project using Swift Package Manager (SPM), open your App in Xcode and open **File > Add Packages**. Then add the SDK by entering the git repo url in the top right search field:

```bash
https://github.com/getsentry/sentry-cocoa.git
```

You can define your dependency rule by selecting the SDK version (or branch), and then click the "Add Package" button. You will then be prompted to choose one of the options `Sentry`, `Sentry-Dynamic` or `SentrySwiftUI`.

* `Sentry` is the static framework, which is the recommended option if you prefer a fast app start time.
* `Sentry-Dynamic` is the dynamic framework.
* `SentrySwiftUI` is used to track performance of SwiftUI views, see more information in the [docs](https://docs.sentry.io/platforms/apple/guides/ios/tracing/instrumentation/swiftui-instrumentation.md).

Xcode allows you to choose many options, but you should choose only one of the options above.

Alternatively, when your project uses a `Package.swift` file to manage dependencies, you can specify the target with:

```swift
.package(url: "https://github.com/getsentry/sentry-cocoa", from: "9.9.0"),
```

## [Building Without UIKit or AppKit](https://docs.sentry.io/platforms/apple/install/swift-package-manager.md#building-without-uikit-or-appkit)

If you're building a command-line tool, a headless server app, or any other target where UIKit or AppKit isn't available, you can use the `NoUIFramework` package trait to strip out UI framework dependencies entirely. This requires **Sentry SDK 9.7.0+**, **Swift 6.1+**, and **Xcode 26.4+**. When enabled, the SDK compiles from source without linking UIKit, AppKit, or SwiftUI. UI-related features like UIViewController tracing and screenshot capture are excluded.

### [Xcode](https://docs.sentry.io/platforms/apple/install/swift-package-manager.md#xcode)

1. Add the Sentry package as described above.
2. Select the **`SentrySPM`** product instead of `Sentry` or `Sentry-Dynamic`.
3. In your project settings, go to **Package Dependencies**, select the Sentry package, and enable the **`NoUIFramework`** trait.

### [Package.swift](https://docs.sentry.io/platforms/apple/install/swift-package-manager.md#packageswift)

Add the dependency with the `NoUIFramework` trait and depend on the `SentrySPM` product:

```swift
let package = Package(
    name: "MyApp",
    dependencies: [
        .package(
            url: "https://github.com/getsentry/sentry-cocoa",
            from: "9.9.0",
            traits: ["NoUIFramework"]
        ),
    ],
    targets: [
        .executableTarget(
            name: "MyApp",
            dependencies: [
                .product(name: "SentrySPM", package: "sentry-cocoa"),
            ]
        ),
    ]
)
```

The `SentrySPM` product compiles the SDK from source. This is required for package traits to take effect, since the pre-built binary targets (`Sentry`, `Sentry-Dynamic`) don't support compile-time configuration.
