Zephyr synchronizes specific keys and/or all of your NSUserDefaults 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.
- CocoaPods Support
- Syncs all your NSUserDefaults (if you wish)
- Syncs only specific keys in NSUserDefaults
- Background monitoring and synchronization between NSUserDefaults and NSUbiquitousKeyValueStore
- Detailed Logging
pod 'Zephyr'
- Add
import Zephyr
to any.Swift
file that references Zephyr via a CocoaPods installation.
- Download Zephyr
- Copy
Zephyr.swift
into your project.
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)
Before performing each sync, Zephyr automatically checks to see if the data in NSUserDefaults 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 NSUserDefaults are registered BEFORE calling any of the Zephyr methods.
Sync all NSUserDefaults
Zephyr.sync()
Sync a specific key or keys (Variadic Option)
Zephyr.sync("MyFirstKey", "MySecondKey", ...)
Sync a specific key or keys (Array Option)
Zephyr.sync(["MyFirstKey", "MySecondKey"])
Add/Remove Keys for Background Monitoring (Variadic Option)
Zephyr.addKeysToBeMonitored("MyFirstKey", "MySecondKey", ...)
Zephyr.removeKeysFromBeingMonitored("MyFirstKey", "MySecondKey", ...)
Add/Remove Keys for Background Monitoring (Array Option)
Zephyr.addKeysToBeMonitored(["MyFirstKey", "MySecondKey"])
Zephyr.removeKeysFromBeingMonitored(["MyFirstKey", "MySecondKey"])
Toggle Automatic Calling of NSUbiquitousKeyValueStore's Synchronization method
Zephyr.syncUbiquitousStoreKeyValueStoreOnChange = true // Default
Zephyr.syncUbiquitousStoreKeyValueStoreOnChange = false // Turns off instantaneous synchronization
Debug Logging
Zephyr.debugEnabled = true // Must be called before sync(_:)
Zephyr.sync()