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

# Swift Package Manager (SPM) | Sentry for tvOS

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 a product — see below for which one to pick.

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

## [Pre-compiled (Recommended)](https://docs.sentry.io/platforms/apple/guides/tvos/install/swift-package-manager.md#pre-compiled-recommended)

These products use pre-built binary frameworks. They don't add to your project's compile time and are the recommended choice for most projects.

* **`Sentry`** — Static pre-built framework. Recommended for most projects as it provides the fastest app start time.
* **`Sentry-Dynamic`** — Dynamic pre-built framework. Use this if your project requires dynamic linking.
* **`SentrySwiftUI`** — Deprecated. SwiftUI view performance tracking is now included in the main `Sentry` product. Do not add this to new projects.

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.16.1"),
```

## [Compile from Source](https://docs.sentry.io/platforms/apple/guides/tvos/install/swift-package-manager.md#compile-from-source)

The **`SentrySPM`** product compiles the SDK from source as part of your project build instead of using a pre-built binary. This is useful if you want to step through SDK code while debugging. Not all product variants are available yet with this option.

### [Building Without UIKit or AppKit](https://docs.sentry.io/platforms/apple/guides/tvos/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/guides/tvos/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/guides/tvos/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.16.1",
            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.

## [SentryObjC](https://docs.sentry.io/platforms/apple/guides/tvos/install/swift-package-manager.md#sentryobjc)

Available from SDK **9.16.0+**.

**SentryObjC** is a pure Objective-C wrapper around the Sentry SDK. It is the recommended integration for any Objective-C project — including those that use Objective-C++ (`.mm` files), have Clang modules disabled (`-fmodules=NO`), or otherwise can't use semantic imports (`@import`) or `-Swift.h`. All public types use the `SentryObjC` prefix and no Swift-related headers appear in the public surface.

### [Why SentryObjC?](https://docs.sentry.io/platforms/apple/guides/tvos/install/swift-package-manager.md#why-sentryobjc)

With Clang modules disabled, `@import Sentry` doesn't work and `#import <Sentry/Sentry-Swift.h>` fails with forward-declaration errors in `.mm` files. This makes `SentrySDK`, `SentryOptions`, and other Swift-bridged APIs unavailable. SentryObjC solves this by providing hand-written Objective-C headers that don't depend on Swift modules or the Swift compiler.

### [Installation](https://docs.sentry.io/platforms/apple/guides/tvos/install/swift-package-manager.md#installation)

SentryObjC is available as both a compile-from-source SPM product and pre-compiled xcframeworks.

**Via SPM (compile from source):** In Xcode, add the Sentry package as described above and select the **`SentryObjC`** product.

With `Package.swift`:

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

Then depend on the `SentryObjC` product:

```swift
.target(
    name: "MyApp",
    dependencies: [
        .product(name: "SentryObjC", package: "sentry-cocoa"),
    ]
)
```

**Via SPM (pre-compiled):** The `SentryObjC-Static` and `SentryObjC-Dynamic` products use pre-built binary frameworks, so they don't add to your project's compile time. Select one of these products instead of `SentryObjC` when adding the package in Xcode, or reference them in `Package.swift`:

```swift
.product(name: "SentryObjC-Static", package: "sentry-cocoa"),
```

Pre-compiled xcframeworks are also available for [manual download](https://docs.sentry.io/platforms/apple/guides/tvos/install/manual-install.md).

### [Configuration](https://docs.sentry.io/platforms/apple/guides/tvos/install/swift-package-manager.md#configuration)

All SentryObjC types use the `SentryObjC` prefix. Import the umbrella header and initialize the SDK:

```objc
#import <SentryObjC/SentryObjC.h>

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    [SentryObjCSDK startWithConfigureOptions:^(SentryObjCOptions *options) {
        options.dsn = @"___PUBLIC_DSN___";
        options.debug = YES;

        // Adds IP for users.
        // For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/
        options.sendDefaultPii = YES;

        // Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring.
        // We recommend adjusting this value in production.
        options.tracesSampleRate = @1.0;
    }];

    return YES;
}
```

If your project has Clang modules enabled and you're using the dynamic variant (`SentryObjC-Dynamic`), you can also use a module import instead:

```objc
@import SentryObjC;
```

SentryObjC embeds the full Sentry SDK. Do not link both `Sentry` and `SentryObjC` in the same target.

### [Additional Build Settings](https://docs.sentry.io/platforms/apple/guides/tvos/install/swift-package-manager.md#additional-build-settings)

#### [SentryObjC-Static](https://docs.sentry.io/platforms/apple/guides/tvos/install/swift-package-manager.md#sentryobjc-static)

When using the static variant (`SentryObjC-Static`) in a pure Objective-C target, additional linker flags are needed because the static framework bundles C++ and Swift code that Xcode doesn't link automatically. If your target already contains at least one `.swift` file, Xcode links the Swift runtime for you and you only need `-lc++`.

Add the following to your target's **Build Settings > Linking - General > Other Linker Flags**:

```bash
-lc++ -lswiftCore -force_load $(DT_TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)/libswiftCompatibility56.a
```

* **`-lc++`** links the C++ standard library, required by the profiler and crash reporter bundled in the static framework.
* **`-lswiftCore`** and the **`-force_load`** flag link the Swift runtime and backward-compatibility stubs. These are only needed when your target has no Swift files. If your target already contains a `.swift` file, Xcode links the Swift runtime automatically and you can omit these two flags.

As a fallback (for example, if the toolchain path causes issues in your build system), you can add an empty Swift file to your target instead of the explicit flags. Create a file such as `Dummy.swift` with no content and its presence forces Xcode to link the Swift runtime:

```swift
// Forces Xcode to link the Swift runtime into this pure-ObjC target.
```

These steps are not needed for `SentryObjC-Dynamic` or the compile-from-source `SentryObjC` product, as dynamic frameworks and SPM source targets handle runtime linking automatically.

#### [Clang Modules Disabled / Objective-C++](https://docs.sentry.io/platforms/apple/guides/tvos/install/swift-package-manager.md#clang-modules-disabled--objective-c)

When your project has Clang modules disabled (`CLANG_ENABLE_MODULES = NO`) or uses Objective-C++ (`.mm` files):

1. **Use `#import` instead of `@import`.** Module imports (`@import SentryObjC;`) require Clang modules to be enabled. Use the header import instead:

   ```objc
   #import <SentryObjC/SentryObjC.h>
   ```

2. **Link system frameworks explicitly.** Without modules, automatic framework linking is unavailable. Add the system frameworks your app uses to **Other Linker Flags**:

   ```bash
   -framework UIKit -framework Foundation
   ```
