<!--
{
  "availability" : [
    "iOS: 17.0.0 -",
    "iPadOS: 17.0.0 -",
    "macCatalyst: 17.0.0 -",
    "macOS: 14.0.0 -",
    "swift: 5.9.0 -",
    "tvOS: 17.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 10.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftData",
  "identifier" : "/documentation/SwiftData/Transient()",
  "metadataVersion" : "0.1.0",
  "role" : "Macro",
  "symbol" : {
    "kind" : "Macro",
    "modules" : [
      "SwiftData"
    ],
    "preciseIdentifier" : "s:9SwiftData9Transientyycfm"
  },
  "title" : "Transient()"
}
-->

# Transient()

Tells SwiftData not to persist the annotated property when managing the owning
class.

```
@attached(peer) macro Transient()
```

## Overview

If your model class has one or more stored properties that you want to omit
from writes to the persistent storage, annotate each of those properties
with the `@Transient` macro.

> Note: By default, SwiftData considers any computed properties to be
> transient. You don’t need to explicitly annotate those properties.

```swift
@Model
class RemoteImage {
    var sourceURL: URL
    var data: Data
    
    @Transient
    var isDownloading = false
    
    init(sourceURL: URL, data: Data = Data(), isDownloading: Bool) {
        self.sourceURL = sourceURL
        self.data = data
        self.isDownloading = isDownloading
    }
}
```

Unless the type of the annotated property is an optional, the
`@Transient` macro requires you to provide a default value. This constraint
enables SwiftData to successfully materialize instances of the enclosing model
class when running fetches.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)