Docs Menu

Upgrade from Stitch to Realm - Swift SDK

On this page

  • Overview
  • New Features
  • Changes

If you have an existing app built with the Stitch SDK, you should migrate your app to use the new Realm SDK. While much of the application logic and flow of information hasn't changed, there are a few changes to how the SDK connects to the realm backend.

  • The Realm Swift SDK supports iOS applications written in Objective-C.
  • The Realm Swift SDK now includes Realm Database, which includes local object storage and Realm Sync.
What's Changed?
The backend app connections previously accessed via StitchAppClient are now available through App. Use App to access authentication functionality such as logging in and getting the current user.
Migrate all occurrences of StitchAppClient to App.
StitchUser was previously the interface to access application users, but now it is User.
Migrate all occurrences of StitchUser to User.
The login API has changed from client.auth.login() to App.login()
Rewrite all authentication logic to use the new login API.
The API to log users out has changed from StitchAppClient.auth.logout() to User.logOut().
Rewrite the application logic to log out using the User object's logOut() method.
The Stitch SDK defined credentials through functions named after the credential type, i.e., AnonymousCredential() for an anonymous credential. The Realm SDK has a class, Credentials, with methods or enums for each credential type, i.e., Credentials.emailPassword().
Use the Realm SDK's Credentials class to create authentication credentials.
The API to call a Realm function has changed from stitchAppClient.callFunction() to app.currentUser?.functions.{myFunction}(), where {myFunction} is the name of the function.
Replace Realm function calls with the new API method, app.currentUser?.functions.{myFunction}()
The interface to the MongoDB Data Access API, containing objects like MongoDatabase, and MongoCollection, has changed. Through Stitch, passing the remoteMongoClientFactory and the string "mongodb-atlas" to StitchAppClient.serviceClient() creates a remote Mongodb client. The Realm Swift SDK creates a remote MongoDB client through the mongoClient method on the logged-in user object.
Replace all mongoClient instantiations with app.currentUser!.mongoClient().
The Realm SDKs do not provide an interface for calling Services (like the Twilio and AWS services).
Convert uses of Third Party Services in your Stitch Application to Realm functions in your Realm application using the AWS and/or Twilio npm packages. For more information, see Add External Dependencies.
←  Test and Debug - Swift SDKAdditional Examples - Swift SDK →
Give Feedback
© 2022 MongoDB, Inc.


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