Install Realm for iOS, macOS, tvOS, and watchOS

MongoDB Realm's Apple platform SDK enables your iOS, macOS, tvOS, and watchOS applications to interact with MongoDB 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 version 10.0 or higher.
  • Target of iOS 8.0 or higher, macOS 10.9 or higher, tvOS 9.0 or higher, or watchOS 2.0 or higher.
  • If you are installing with CocoaPods, you need CocoaPods 1.10.0 or later.

Follow the procedure for either SwiftPM or CocoaPods below to add the MongoDB Realm Apple platform SDK to your project.


In Xcode, select File > Swift Packages > Add Package Dependency.


Copy and paste the following into the search/input box, then click Next.

Leave the default value of Up to Next Major, then click Next.


Select both Realm and RealmSwift, then click Finish.


On the command line, run pod repo update to ensure CocoaPods can access the latest available Realm versions.


If you do not already have a Podfile for your project, run pod init in the root directory of your project to create a Podfile for your project. A Podfile allows you to specify project dependencies to CocoaPods.


Add the line use_frameworks! if it is not already there.

Add the line pod 'RealmSwift', '=10.1.4' to your main and test targets.

When done, your Podfile should look something like this:

platform :ios, '12.0'
target 'MyRealmProject' do
# Comment the next line if you don't want to use dynamic frameworks
# Pods for MyRealmProject
pod 'RealmSwift', '=10.1.4'

From the command line, run pod install to fetch the dependencies.


CocoaPods generates an .xcworkspace file for you. This file has all of the dependencies configured. From now on, open this file -- not the .xcodeproj file -- to work on your project.

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

import RealmSwift
Give Feedback