You need to have Xcode 9.0 or later installed. Older versions of Xcode cannot be used with this guide.

Building the Realm Tasks Applications

The Realm Tasks demo application is a great way to see how the Realm Object Server works in practice, and to experiment with its functionality. This tutorial will show you how to get started, running the demo application on both your Mac and on the iPhone simulator in order to demonstrate real-time synchronization.

RealmTasks for iOS

Get the app

First, install and start the Realm Object Server by following the instructions in our Installation section.

Next, clone the Realm Tasks repository using git. The GitHub repository for Realm Tasks can be found here. This repository contains the source code for both the macOS and iOS versions of the Realm Tasks demo application. We are going to build and run this application for macOS, as well as for the iOS simulator that is part of Xcode.

Build and run the app for macOS

Make sure you’ve started the Realm Object Server before proceeding.

Open up the “RealmTasks” directory and navigate to “RealmTasks Apple”.

Realm Tasks manages its dependencies using CocoaPods, so open up a terminal window, navigate to the “RealmTasks Apple” directory, and then run pod install. If you don’t already have CocoaPods installed on your computer, refer to their Getting Started guide to install it.

Once the dependencies have been installed, open RealmTasks.xcworkspace. Once Xcode launches, make sure the “RealmTasks macOS” scheme is selected in the drop-down menu. Then you can simply press the build/run arrow in the Xcode toolbar to build and run the application.

Note: If you get any errors, for example, “Module ‘Cartography’ not found”, you have probably opened the Xcode project file instead of the workspace file; simply close the Xcode window and make sure you open the RealmTasks.xcworkspace file.

When the macOS version of Realm Tasks launches, you’ll see a log in screen with a “Register…” button. Click the button and create a new account.

Once you’ve created an account, you’ll be on the application’s main screen. You can click the plus button to add a new task, or the lists button to create or switch task lists. Try making a few tasks in the default list.

Build and run the app for iOS

Without quitting the macOS app or stopping the Realm Object Server, switch back to Xcode and change the scheme to “RealmTasks iOS”, and choose your favorite iOS simulator. Then press the build/run arrow in the Xcode toolbar to build and run the application.

Once the app launches, you can log in to the app using the same username and password you created when your launched RealmTasks for macOS. Instantly after you log in, the iOS app on the simulator will synchronize itself with the Realm Object Server and all of the tasks you entered in the macOS version will show up in the iOS version.

You can enter new tasks using the mouse by clicking on the iOS simulator and slowly dragging downward until a new Task list entry appears. Any entries you create will be instantly synchronized by the Realm Object Server and appear on the macOS version and vice-versa. Swiping left or right on items in the Task List in the iOS app will delete or mark items as ‘done’. Here too, these changes will be immediately reflected in the other version of the application.

Observing Realm changes in Realm Studio

If you wish, download our Realm Studio developer tool and set it up. You can simply connect to the default server.

As you add, edit, or delete items in the macOS or iOS versions of the app, you can also see these changes reflected immediately in Realm Studio as well. These changes reflect the state of the shared Realm itself, and any changes you make to the Realm in Realm Studio will in turn be reflected back onto the macOS and iOS versions of the app!