---
title: "Upgrade from 4.x to 5.x"
description: "Learn about migrating from Sentry Cocoa SDK 4.x to 5.x."
url: https://docs.sentry.io/platforms/apple/guides/tvos/migration/v4-to-v5/
---

# Upgrade from 4.x to 5.x | Sentry for tvOS

The samples below illustrate how the SDK works:

## [Initialization](https://docs.sentry.io/platforms/apple/guides/tvos/migration/v4-to-v5.md#initialization)

Example in 4.x:

```swift
do {
    Client.shared = try Client(dsn: "___PUBLIC_DSN___")
    try Client.shared?.startCrashHandler()
} catch let error {
    print("\(error)")
}
```

Example in 5.x:

```swift
SentrySDK.start(options: [
    "dsn": "___PUBLIC_DSN___",
    "debug": true
])
```

## [Add Breadcrumb](https://docs.sentry.io/platforms/apple/guides/tvos/migration/v4-to-v5.md#add-breadcrumb)

Example in 4.x:\`

```swift
Client.shared?.breadcrumbs.add(Breadcrumb(level: .info, category: "test"))
```

Example in 5.x:

```swift
SentrySDK.addBreadcrumb(Breadcrumb(level: .info, category: "test"))
```

## [CaptureMessage with tags/environment/extra](https://docs.sentry.io/platforms/apple/guides/tvos/migration/v4-to-v5.md#capturemessage-with-tagsenvironmentextra)

Example in 4.x:

```swift
let event = Event(level: .debug)
event.message = "Test Message"
event.environment = "staging"
event.extra = ["ios": true]
Client.shared?.send(event: event)
```

Example in 5.x:

```swift
SentrySDK.capture(message: "Test Message") { (scope) in
    scope.setEnvironment("staging")
    scope.setExtras(["ios": true])
    let u = Sentry.User(userId: "1")
    u.email = "tony@example.com"
    scope.setUser(u)
}
```

## [setUser](https://docs.sentry.io/platforms/apple/guides/tvos/migration/v4-to-v5.md#setuser)

Example in 4.x:

```swift
let u = User(userId: "1")
u.email = "tony@example.com"
Client.shared?.user = user
```

Example in 5.x:

```swift
let u = Sentry.User(userId: "1")
u.email = "tony@example.com"
SentrySDK.setUser(u)
```
