Skip to content

About Quickstart in Couchbase Lite using a standalone database with iOS and Swift. This tutorial will show you how to use Sync Gateway to sync information between your local database and Couchbase Server.

License

Notifications You must be signed in to change notification settings

couchbase-examples/ios-swift-cblite-userprofile-sync

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Quickstart in Couchbase Lite Sync with Swift and UIKit

Build an iOS App in Swift with Couchbase Lite

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.

Prerequisites

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

Installing Couchbase Lite Framework

The Couchbase Documentation has examples on how to add Couchbase Lite via

  • Swift Package Manager
  • Cocoa Pods
  • Carthage
  • Direct Download

App Architecture

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

Try it out

  • Open src/UserProfileSyncDemo.xcodeproj using Xcode
  • Build and run the project.
  • Verify that you see the login screen.

Conclusion

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.

About

About Quickstart in Couchbase Lite using a standalone database with iOS and Swift. This tutorial will show you how to use Sync Gateway to sync information between your local database and Couchbase Server.

Topics

Resources

License

Stars

Watchers

Forks