Couchbase Sync Gateway is a key component of the Couchbase Mobile stack. It is an Internet-facing synchronization mechanism that securely syncs data across devices as well as between devices and the cloud. Couchbase Mobile 3.0 introduces centralized persistent module configuration of synchronization, which simplifies the administration of Sync Gateway clusters — see Sync Gateway Configuration.
The core functions of the Sync Gateway include
- Data Synchronization across devices and the cloud
- Authorization & Access Control
- Data Validation
This tutorial will demonstrate how to
- Setup the Couchbase Sync Gateway (with Docker) to sync content between multiple Couchbase Lite enabled clients. We will will cover the basics of the Sync Gateway Configuration.
- Configure your Sync Gateway to enforce data routing, access control and authorization. We will cover the basics of Sync Function API
- Configure your Couchbase Lite clients for replication with the Sync Gateway
- Use "Live Queries" or Query events within your Couchbase Lite clients to be asynchronously notified of changes
Full documentation can be found on the Couchbase Developer Portal.
To run this prebuilt project, you will need:
- Mac running MacOS 12 or 13
- Xcode 13/14 - Download latest version from the Mac App Store or via Xcodes
Note: If you are using an older version of Xcode, which you need to retain for other development needs, make a copy of your existing version of Xcode and install the latest Xcode version. That way you can have multiple versions of Xcode on your Mac. More information can be found in Apple's Developer Documentation
The Couchbase Documentation has examples on how to add Couchbase Lite via
- Swift Package Manager
- Cocoa Pods
- Carthage
- Direct Download
The sample app follows the MVP pattern, separating the internal data model, from a passive view through a presenter that handles the logic of our application and acts as the conduit between the model and the view
- Open
src/UserProfileSyncDemo.xcodeproj
using Xcode - Build and run the project.
- Verify that you see the login screen.
This tutorial walked you through an example of how to use a Sync Gateway to synchronize data between Couchbase Lite enabled clients. We discussed how to configure your Sync Gateway to enforce relevant access control, authorization and data routing between Couchbase Lite enabled clients.