Effortlessly synchronize UserDefaults over iCloud.
Clone or download
Latest commit 51db050 Nov 11, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Assets Updated README Mar 4, 2017
Sources Updated for swift4.2 Sep 17, 2018
ZephyrExample Updated for swift4.2 Sep 17, 2018
docs Updated docs Apr 23, 2018
.gitignore Initial commit Nov 4, 2015
.jazzy.yml Added SwiftLint. Added JazzyDocs. Fixed SwiftPM support Mar 4, 2017
.swiftlint.yml Swift 4 and Xcode 9 Support (#24) Sep 13, 2017
Gemfile Updated Gemfile Jan 7, 2017
Gemfile.lock Updated for swift4.2 Sep 17, 2018
LICENSE Initial commit Nov 4, 2015
Package.swift Added Swift PM support Feb 8, 2016
README.md Update README.md Nov 11, 2018
Zephyr.podspec Updated for swift4.2 Sep 17, 2018

README.md

Zephyr 🌬️

Effortlessly sync UserDefaults over iCloud

Swift Support Platform Documentation

CocoaPods Carthage Compatible SwiftPM Compatible


About

Zephyr synchronizes specific keys and/or all of your UserDefaults over iCloud using NSUbiquitousKeyValueStore.

Zephyr has built in monitoring, allowing it to sync specific keys in the background as they change.

For the latest updates, refer to the Releases tab.

Features

  • CocoaPods Support
  • Syncs all your UserDefaults (if you wish)
  • Syncs only specific keys in UserDefaults
  • Background monitoring and synchronization between UserDefaults and NSUbiquitousKeyValueStore
  • Detailed Logging
  • Documentation at http://sabintsev.com/Zephyr/

Installation Instructions

Swift Version Branch Name Will Continue to Receive Updates?
4.1 master Yes
4.1 swift4.1 No
3.2 swift3.2 No
3.1 swift3.1 No

CocoaPods

pod 'Zephyr' # Swift 4.2
pod 'Zephyr', :git => 'https://github.com/ArtSabintsev/Zephyr.git', :branch => 'swift4.1' # Swift 4.1
pod 'Zephyr', :git => 'https://github.com/ArtSabintsev/Zephyr.git', :branch => 'swift3.2' # Swift 3.2
pod 'Zephyr', :git => 'https://github.com/ArtSabintsev/Zephyr.git', :branch => 'swift3.1' # Swift 3.1

Carthage

github "ArtSabintsev/Zephyr" // Swift 4.2
github "ArtSabintsev/Zephyr" "swift4.1" // Swift 4.1
github "ArtSabintsev/Zephyr" "swift3.2" // Swift 3.2
github "ArtSabintsev/Zephyr" "swift3.1" // Swift 3.1

Swift Package Manager

.Package(url: "https://github.com/ArtSabintsev/Zephyr.git", majorVersion: 3)

Manual

  1. Download Zephyr
  2. Copy Zephyr.swift into your project.

Setup

Turn on iCloud Sync in Xcode

In Xcode, open your app's project/workspace file:

  • Click on your Project
  • Click on one of your Targets
  • Click on Capabilities
  • Turn on iCloud syncing
  • Under Services, make sure to check Key-value storage
  • Repeat for all Targets (if necessary)

How to turn on iCloud Key Value Store Syncing

Integrate Zephyr into your App

Before performing each sync, Zephyr automatically checks to see if the data in UserDefaults or NSUbiquitousKeyValueStore is newer. To make sure there's no overwriting going on in a fresh installation of your app on a new device that's connected to the same iCloud account, make sure that your UserDefaults are registered BEFORE calling any of the Zephyr methods. One way to easily achieve this is by using the UserDefaults Register API.

Sync all UserDefaults

Zephyr.sync()

Sync a specific key or keys (Variadic Option)

Zephyr.sync(keys: "MyFirstKey", "MySecondKey", ...)

Sync a specific key or keys (Array Option)

Zephyr.sync(keys: ["MyFirstKey", "MySecondKey"])

Add/Remove Keys for Background Monitoring (Variadic Option)

Zephyr.addKeysToBeMonitored(keys: "MyFirstKey", "MySecondKey", ...)
Zephyr.removeKeysFromBeingMonitored(keys: "MyFirstKey", "MySecondKey", ...)

Add/Remove Keys for Background Monitoring (Array Option)

Zephyr.addKeysToBeMonitored(keys: ["MyFirstKey", "MySecondKey"])
Zephyr.removeKeysFromBeingMonitored(keys: ["MyFirstKey", "MySecondKey"])

Toggle Automatic Calling of NSUbiquitousKeyValueStore's Synchronization method

Zephyr.syncUbiquitousKeyValueStoreOnChange = true // Default
Zephyr.syncUbiquitousKeyValueStoreOnChange = false // Turns off instantaneous synchronization

Debug Logging

Zephyr.debugEnabled = true // Must be called before sync(_:)
Zephyr.sync()

Sample App

Please ignore the Sample App as I did not add any demo code in the Sample App. It's only in this repo to add support for Carthage.

Created and maintained by

Arthur Ariel Sabintsev