All Projects → Sorix → Cloudcore

Sorix / Cloudcore

Licence: mit
Framework that enables syncing between iCloud (CloudKit) and Core Data

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Cloudcore

Sync
JSON to Core Data and back. Swift Core Data Sync.
Stars: ✭ 2,538 (+1638.36%)
Mutual labels:  sync, coredata, cocoapods
Corestore
Unleashing the real power of Core Data with the elegance and safety of Swift
Stars: ✭ 3,254 (+2128.77%)
Mutual labels:  coredata, cocoapods, swift-package-manager
Zephyr
Effortlessly synchronize UserDefaults over iCloud.
Stars: ✭ 722 (+394.52%)
Mutual labels:  sync, cocoapods, swift-package-manager
Freedom
The Freedom to Open URLs in Third-Party Browsers on iOS with Custom UIActivity Subclasses.
Stars: ✭ 85 (-41.78%)
Mutual labels:  cocoapods, swift-package-manager
Dikit
Dependency Injection Framework for Swift, inspired by KOIN.
Stars: ✭ 77 (-47.26%)
Mutual labels:  cocoapods, swift-package-manager
Swiftlinkpreview
It makes a preview from an URL, grabbing all the information such as title, relevant texts and images.
Stars: ✭ 1,216 (+732.88%)
Mutual labels:  cocoapods, swift-package-manager
Burritos
A collection of Swift Property Wrappers (formerly "Property Delegates")
Stars: ✭ 1,139 (+680.14%)
Mutual labels:  cocoapods, swift-package-manager
Buckets Swift
Swift Collection Data Structures Library
Stars: ✭ 106 (-27.4%)
Mutual labels:  cocoapods, swift-package-manager
Xmlmapper
A simple way to map XML to Objects written in Swift
Stars: ✭ 90 (-38.36%)
Mutual labels:  cocoapods, swift-package-manager
Swifterswift
A handy collection of more than 500 native Swift extensions to boost your productivity.
Stars: ✭ 10,706 (+7232.88%)
Mutual labels:  cocoapods, swift-package-manager
Bettersegmentedcontrol
An easy to use, customizable replacement for UISegmentedControl & UISwitch.
Stars: ✭ 1,782 (+1120.55%)
Mutual labels:  cocoapods, swift-package-manager
Ducttape
📦 KeyPath dynamicMemberLookup based syntax sugar for Swift.
Stars: ✭ 138 (-5.48%)
Mutual labels:  cocoapods, swift-package-manager
Dtgradientbutton
Easy way to set gradient background to your buttons.
Stars: ✭ 76 (-47.95%)
Mutual labels:  cocoapods, swift-package-manager
Jotify
Sticky notes reimagined - written in Swift
Stars: ✭ 79 (-45.89%)
Mutual labels:  cloudkit, coredata
Loadingshimmer
An easy way to add a shimmering effect to any view with just one line of code. It is useful as an unobtrusive loading indicator.
Stars: ✭ 1,180 (+708.22%)
Mutual labels:  cocoapods, swift-package-manager
Predicateflow
Write amazing, strong-typed and easy-to-read NSPredicate.
Stars: ✭ 98 (-32.88%)
Mutual labels:  coredata, cocoapods
Randomkit
Random data generation in Swift
Stars: ✭ 1,458 (+898.63%)
Mutual labels:  cocoapods, swift-package-manager
Calendarkit
📅 Calendar for Apple platforms in Swift
Stars: ✭ 2,049 (+1303.42%)
Mutual labels:  cocoapods, swift-package-manager
Natrium
A pre-build (Swift) script to alter your Xcode project at pre-build-time per environment, build configuration and target.
Stars: ✭ 131 (-10.27%)
Mutual labels:  cocoapods, swift-package-manager
Outlookgooglecalendarsync
Sync your Outlook and Google calendars
Stars: ✭ 1,113 (+662.33%)
Mutual labels:  sync, synchronization

Archived

Nowdays repository is not actively maintained, so I put that repo in an archived state because I can't provide high-quality support and actual updates for that project. Maybe a little later I could take control of that and push a new version of CloudCore.

I recommend looking at Deeje's pull request, he has implemented a lot of fixes and new features, but it's not my code so I couldn't guarantee anything.

CloudCore

Documentation Version Platform Status Swift

CloudCore is a framework that manages syncing between iCloud (CloudKit) and Core Data written on native Swift. It maybe used are CloudKit caching.

Features

  • Sync manually or on push notifications.
  • Differential sync, only changed object and values are uploaded and downloaded. CloudCore even differs changed and not changed values inside objects.
  • Respects of Core Data options (cascade deletions, external storage).
  • Knows and manages with CloudKit errors like userDeletedZone, zoneNotFound, changeTokenExpired, isMore.
  • Covered with Unit and CloudKit online tests.
  • All public methods are 100% documented.
  • Currently only private database is supported.

How it works?

CloudCore is built using "black box" architecture, so it works invisibly for your application, you just need to add several lines to AppDelegate to enable it. Synchronization and error resolving is managed automatically.

  1. CloudCore stores change tokens from CloudKit, so only changed data is downloaded.
  2. When CloudCore is enabled (CloudCore.enable) it fetches changed data from CloudKit and subscribes to CloudKit push notifications about new changes.
  3. When CloudCore.fetchAndSave is called manually or by push notification, CloudCore fetches and saves changed data to Core Data.
  4. When data is written to persistent container (parent context is saved) CloudCore founds locally changed data and uploads it to CloudKit.

Installation

CocoaPods

CloudCore is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'CloudCore', '~> 2.0'

How to help?

Current version of framework hasn't been deeply tested and may contain errors. If you can test framework, I will be very glad. If you found an error, please post an issue.

Documentation

All public methods are documented using XCode Markup and available inside XCode. HTML-generated version of that documentation is available here.

Quick start

  1. Enable CloudKit capability for you application: CloudKit capability

  2. Add 2 service attributes to each entity in CoreData model you want to sync:

  • recordData attribute with Binary type
  • recordID attribute with String type
  1. Make changes in your AppDelegate.swift file:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
  // Register for push notifications about changes
  application.registerForRemoteNotifications()

  // Enable CloudCore syncing
  CloudCore.enable(persistentContainer: persistentContainer)

  return true
}

// Notification from CloudKit about changes in remote database
func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
  // Check if it CloudKit's and CloudCore notification
  if CloudCore.isCloudCoreNotification(withUserInfo: userInfo) {
    // Fetch changed data from iCloud
    CloudCore.fetchAndSave(using: userInfo, to: persistentContainer, error: nil, completion: { (fetchResult) in
      completionHandler(fetchResult.uiBackgroundFetchResult)
    })
  }
}

func applicationWillTerminate(_ application: UIApplication) {
	// Save tokens on exit used to differential sync
	CloudCore.tokens.saveToUserDefaults()
}
  1. Make first run of your application in a development environment, fill an example data in Core Data and wait until sync completes. CloudCore create needed CloudKit schemes automatically.

Service attributes

CloudCore stores service CloudKit information in managed objects, you need to add that attributes to your Core Data model. If required attributes are not found in entity that entity won't be synced.

Required attributes for each synced entity:

  1. Record Data attribute with Binary type
  2. Record ID attribute with String type

You may specify attributes' names in 2 ways (you may combine that ways in different entities).

User Info

First off CloudCore try to search attributes by looking up User Info at your model, you may specify User Info key CloudCoreType for attribute to mark one as service one. Values are:

  • Record Data value is recordData.
  • Record ID value is recordID.

Model editor User Info

Default names

The most simple way is to name attributes with default names because you don't need to specify any User Info.

💡 Tips

  • You can name attribute as you want, value of User Info is not changed (you can create attribute myid with User Info: CloudCoreType: recordID)
  • I recommend to mark Record ID attribute as Indexed, that can speed up updates in big databases.
  • Record Data attribute is used to store archived version of CKRecord with system fields only (like timestamps, tokens), so don't worry about size, no real data will be stored here.

Example application

You can find example application at Example directory.

How to run it:

  1. Set Bundle Identifier.
  2. Check that embedded binaries has a correct path (you can remove and add again CloudCore.framework).
  3. If you're using simulator, login at iCloud on it.

How to use it:

  • + button adds new object to local storage (that will be automatically synced to Cloud)
  • refresh button calls fetchAndSave to fetch data from Cloud. That is useful button for simulators because Simulator unable to receive push notifications
  • Use CloudKit dashboard to make changes and see it at application, and make change in application and see ones in dashboard. Don't forget to refresh dashboard's page because it doesn't update data on-the-fly.

Tests

CloudKit objects can't be mocked up, that's why I create 2 different types of tests:

  • Tests/Unit here I placed tests that can be performed without CloudKit connection. That tests are executed when you submit a Pull Request.

  • Tests/CloudKit here located "manual" tests, they are most important tests that can be run only in configured environment because they work with CloudKit and your Apple ID.

    Nothing will be wrong with your account, tests use only private CKDatabase for application.

    Please run these tests before opening pull requests. To run them you need to:

    1. Change TestableApp bundle id.
    2. Run in simulator or real device TestableApp target.
    3. Configure iCloud on that device: Settings.app → iCloud → Login.
    4. Run CloudKitTests, they are attached to TestableApp, so CloudKit connection will work.

Roadmap

  • [x] Move from alpha to beta status.
  • [ ] Add CloudCore.disable method
  • [ ] Add methods to clear local cache and remote database
  • [ ] Add error resolving for limitExceeded error (split saves by relationships).

Author

Open for hire / relocation. Vasily Ulianov, [email protected]

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].