All Projects → nofelmahmood → Seam

nofelmahmood / Seam

Licence: mit
Seamless CloudKit Sync with CoreData

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Seam

Cloudcore
Framework that enables syncing between iCloud (CloudKit) and Core Data
Stars: ✭ 146 (-77.85%)
Mutual labels:  cloudkit, sync
Zephyr
Effortlessly synchronize UserDefaults over iCloud.
Stars: ✭ 722 (+9.56%)
Mutual labels:  sync, carthage
Seam3
Cloudkit based persistent store for Core Data
Stars: ✭ 207 (-68.59%)
Mutual labels:  cloudkit, sync
Sync
JSON to Core Data and back. Swift Core Data Sync.
Stars: ✭ 2,538 (+285.13%)
Mutual labels:  sync, carthage
Crdt Playground
Stars: ✭ 215 (-67.37%)
Mutual labels:  cloudkit, sync
Hotkey
Simple global shortcuts in macOS
Stars: ✭ 574 (-12.9%)
Mutual labels:  carthage
Weibo Picture Store
🖼 新浪微博图床 Chrome/Firefox 扩展,支持同步到微相册
Stars: ✭ 624 (-5.31%)
Mutual labels:  sync
Swiftinstagram
Instagram API client written in Swift
Stars: ✭ 570 (-13.51%)
Mutual labels:  carthage
Sdwebimage
Asynchronous image downloader with cache support as a UIImageView category
Stars: ✭ 23,928 (+3530.96%)
Mutual labels:  carthage
Flexiblepagecontrol
A flexible UIPageControl like Instagram.
Stars: ✭ 638 (-3.19%)
Mutual labels:  carthage
Urlembeddedview
URLEmbeddedView automatically caches the object that is confirmed the Open Graph Protocol.
Stars: ✭ 633 (-3.95%)
Mutual labels:  carthage
Evcloudkitdao
Simplified access to Apple's CloudKit
Stars: ✭ 618 (-6.22%)
Mutual labels:  cloudkit
Malsync
Integrates MyAnimeList/AniList/Kitsu/Simkl into various sites, with auto episode tracking.
Stars: ✭ 572 (-13.2%)
Mutual labels:  sync
Jlroutes
URL routing library for iOS with a simple block-based API
Stars: ✭ 5,528 (+738.85%)
Mutual labels:  carthage
Sidemenu
Simple side/slide menu control for iOS, no code necessary! Lots of customization. Add it to your project in 5 minutes or less.
Stars: ✭ 5,267 (+699.24%)
Mutual labels:  carthage
Stlocationrequest
Request the Location Services via a 3D 360° flyover MKMapView 🗺
Stars: ✭ 636 (-3.49%)
Mutual labels:  carthage
Git Ftp
Uses Git to upload only changed files to FTP servers.
Stars: ✭ 5,104 (+674.51%)
Mutual labels:  sync
Multiprogressview
📊 An animatable view that depicts multiple progresses over time. Modeled after UIProgressView
Stars: ✭ 614 (-6.83%)
Mutual labels:  carthage
Kydrawercontroller
Side Drawer Navigation Controller similar to Android
Stars: ✭ 632 (-4.1%)
Mutual labels:  carthage
Orsserialport
Serial port library for Objective-C and Swift macOS apps
Stars: ✭ 609 (-7.59%)
Mutual labels:  carthage

seamlogo

Pod Version Carthage Compatible Platform License

Seam allows you to sync your CoreData Stores with CloudKit.

Topics

Features

  • Automatic mapping of CoreData Models to CloudKit Private Databases
  • Supports Assets
  • Background Sync
  • Conflict Resolution

Requirements

  • iOS 8.0+ / Mac OS X 10.10+
  • Xcode 7.1+

Communication

Please read the Contributing Guidelines before doing any of above.

Installation

Cocoapods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

To integrate Seam into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!

pod 'Seam', '~> 0.6'

Then, run the following command:

$ pod install

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

To integrate Seam into your Xcode project using Carthage, specify it in your Cartfile:

github "Seam/Seam" ~> 0.6

Run carthage update to build the framework and drag the built Seam.framework into your Xcode project.

Usage

Add a Store type of SeamStoreType to a NSPersistentStoreCoordinator in your CoreData stack:

let persistentStoreCoordinator = NSPersistentStoreCoordinator(managedObjectModel: yourModel)
let seamStore = try persistentStoreCoordinator.addPersistentStoreWithType(SeamStoreType, 
                                                                          configuration: nil, 
                                                                          URL: url, options: nil) as? Store

Observe the following two Notifications to know when the Sync Operation starts and finishes:

NSNotificationCenter.defaultCenter().addObserver(self, selector: "didStartSyncing:",
                                                name: SMStoreDidStartSyncingNotification,
                                                object: seamStore)

NSNotificationCenter.defaultCenter().addObserver(self, selector: "didFinishSyncing:",
                                                name: SMStoreDidFinishSyncingNotification,
                                                object: seamStore)                                               

func didStartSyncing(notification: NSNotification) {
  // Prepare for new data before syncing completes
}
  
func didFinishSyncing(notification: NSNotification) {
  // Merge Changes into your context after syncing completes
  mainContext.mergeChangesFromStoreDidFinishSyncingNotification(notification)
}
  

Finally call sync whenever and wherever you want:

seamStore.sync(nil)

To trigger sync whenever a change happens on the CloudKit Servers. Subscribe the store to receive Push Notifications from the CloudKit Servers.

seamStore.subscribeToPushNotifications({ successful in
    guard successful else { return }
    // Ensured that subscription was created successfully
})

// In your AppDelegate

func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject]) {
    seamStore.sync(nil)
}

Attributes

All CloudKit Attributes are mapped automatically to your CoreData attributes with the exception of CKAsset and CLLocation.

CKAsset and CLLocation can be used by setting the corresponding attribute as Transformable in your CoreData Model.

CloudKit CoreData
NSDate NSDate
NSData NSData
NSString NSString
NSNumber NSNumber
CKReference NSManagedObject
CKAsset Transformable
CLLocation Transformable

Transformable Attributes

CKAsset and CLLocation can be used in your CoreData model as Transformable attributes.

  1. To use CKAsset set Transformable as AttributeType and CKAssetTransformer as value transformer name for the attribute.

  1. To use CLLocation set Transformable as AttributeType and CLLocationTransformer as value transformer name for the attribute.

Relationships

CoreData Relationship Translation on CloudKit
To - one To one relationships are translated as CKReferences on the CloudKit Servers.
To - many To many relationships are not explicitly created. Seam only creates and manages to-one relationships on the CloudKit Servers.
Example -> If an Employee has a to-one relationship to Department and Department has a to-many relationship to Employee than Seam will only create the former on the CloudKit Servers. It will fullfil the later by using the to-one relationship. If all employees of a department are accessed Seam will fulfil it by fetching all the employees that belong to that particular department.

Note : You must create inverse relationships in your app's CoreData Model or Seam wouldn't be able to translate CoreData Models in to CloudKit Records. Unexpected errors and curroption of data can possibly occur.

Getting Started

Download the demo project. Run it and see the magic as it happens.

FAQ

tvOS Support ?

tvOS provides no persistent local storage. Seam uses SQLITE file to keep a local copy of your database which is not possible with tvOS.

Apps

A list of Apps which are using Seam.

Author

Seam is owned and maintained by Nofel Mahmood.

You can follow him on Twitter and Medium

License

Seam is available under the MIT license. See the LICENSE file for more info.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].