Docs Menu

Docs HomeRealm

Install Realm for iOS, macOS, tvOS, and watchOS

On this page

  • Overview
  • Prerequisites
  • Installation
  • Import Realm
  • App Download File Size
  • Troubleshooting
  • OS Support
  • Swift Concurrency Support

Realm's Swift SDK enables your iOS, macOS, tvOS, and watchOS applications to interact with Realm using either the Swift or Objective-C programming languages. This page details how to install Realm in your project and get started.

Before getting started, ensure your development environment meets the following prerequisites:

  • Xcode 14.1-14.3.1 with a target of iOS 11.0 or higher, macOS 10.13 or higher, tvOS 11.0 or higher, or watchOS 4.0 or higher.

  • Reflection is enabled in your project. The Realm Swift SDK uses reflection to determine your model's properties. Your project must not set SWIFT_REFLECTION_METADATA_LEVEL = none or Realm cannot see properties in your model. Reflection is enabled by default if your project does not specifically set a level for this setting.

Changed in version 10.40.0.

Swift SDK version 10.40.0 drops support for Xcode 13. For v10.39.01 and earlier, these Xcode 13 requirements apply:

  • Xcode version 13.1 or higher.

  • When using Xcode 13, a target of iOS 9.0 or higher, macOS 10.9 or higher, tvOS 9.0 or higher, or watchOS 2.0 or higher.

  • If using Swift Package Manager with Xcode 13, target of iOS 11+ or macOS 10.10+ is required.

Note

There are special considerations when using Realm with tvOS. See Build for tvOS for more information.

You can use SwiftPM, CocoaPods, or Carthage to add the Realm Swift SDK to your project.

Add the following line at the top of your source files to use Realm:

Realm should only add around 5 to 8 MB to your app's download size. The releases we distribute are significantly larger because they include support for the iOS, watchOS and tvOS simulators, some debug symbols, and bitcode, all of which are stripped by the App Store automatically when apps are downloaded.

If you have build issues after using one of these methods to install Realm, see our troubleshooting guidelines for information about resolving those issues in realm.

Important

There are special considerations when using Realm with tvOS. See Build for tvOS for more information.

Supported OS
Realm
Atlas App Services
iOS 11.0+
X
X
macOS 10.13+
X
X
tvOS 11.0+
X
X
watchOS 4.0+
X

New in version 10.40.1.

Supported OS
Realm
Atlas App Services
iOS 12.0+
X
X
macOS 10.13+
X
X
tvOS 11.0+
X
X
watchOS 4.0+
X
visionOS 1.0+
X
X

The Realm Swift SDK supports Swift's concurrency-related language features. For best practices on using Realm with Swift concurrency features, refer to the documentation below.

Starting with Realm Swift SDK Versions 10.15.0 and 10.16.0, many of the Realm APIs support the Swift async/await syntax. Projects must meet these requirements:

Swift SDK Version
Swift Version Requirement
Supported OS
10.25.0
Swift 5.6
iOS 13.x
10.15.0 or 10.16.0
Swift 5.5
iOS 15.x

If your app accesses Realm in an async/await context, mark the code with @MainActor to avoid threading-related crashes.

For more information about async/await support in the Realm Swift SDK, refer to Swift Concurrency: Async/Await APIs.

The Realm Swift SDK supports actor-isolated realm instances. For more information, refer to Actor-Isolated Realms - Swift SDK.

←  Realm - Swift SDKQuick Start - Swift SDK →
Share Feedback
© 2023 MongoDB, Inc.

About

  • Careers
  • Investor Relations
  • Legal Notices
  • Privacy Notices
  • Security Information
  • Trust Center
© 2023 MongoDB, Inc.