kirankunigiri / Zephyr

Effortlessly synchronize NSUserDefaults over iCloud.

Home Page:http://www.sabintsev.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Zephyr

Effortlessly sync NSUserDefaults over iCloud

CocoaPods Carthage Compatible SwiftPM Compatible CocoaPods CocoaPods

About

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.

Features

  • 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

Installation Instructions

CocoaPods

For Swift 3 support:

pod 'Zephyr'

For Swift 2.3 support:

pod 'Zephyr', :git => 'https://github.com/ArtSabintsev/Zephyr.git', :branch => 'swift2.3'

Carthage

For Swift 3 support:

github "ArtSabintsev/Zephyr"

For Swift 2.3 support:

github "ArtSabintsev/Zephyr" "swift2.3"

Swift Package Manager

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

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 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(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

About

Effortlessly synchronize NSUserDefaults over iCloud.

http://www.sabintsev.com

License:MIT License


Languages

Language:Swift 88.2%Language:Ruby 9.8%Language:Objective-C 2.0%