All Projects → arturgrigor → Cloudkitgdpr

arturgrigor / Cloudkitgdpr

Licence: mit
Framework for allowing users to manage data stored in iCloud

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Cloudkitgdpr

Xcake
🍰 Describe Xcode projects in a human readable format and (re)generate one on demand.
Stars: ✭ 549 (+335.71%)
Mutual labels:  xcode, tvos, watchos, cocoapods
Fugen
Command line tool for exporting resources and generating code from your Figma files
Stars: ✭ 41 (-67.46%)
Mutual labels:  xcode, tvos, watchos, cocoapods
Swifterswift
A handy collection of more than 500 native Swift extensions to boost your productivity.
Stars: ✭ 10,706 (+8396.83%)
Mutual labels:  xcode, tvos, watchos, cocoapods
Cdmarkdownkit
An extensive Swift framework providing simple and customizable markdown parsing.
Stars: ✭ 158 (+25.4%)
Mutual labels:  xcode, tvos, watchos, cocoapods
Sqift
Powerful Swift wrapper for SQLite
Stars: ✭ 119 (-5.56%)
Mutual labels:  xcode, tvos, watchos, cocoapods
Swiftui Grid
🚀 SwiftUI Grid layout with custom styles
Stars: ✭ 872 (+592.06%)
Mutual labels:  xcode, tvos, watchos
Sqlitelib
Easily build a custom SQLite static library for use in macOS and iOS frameworks and apps.
Stars: ✭ 38 (-69.84%)
Mutual labels:  xcode, tvos, watchos
Swiftysound
SwiftySound is a simple library that lets you play sounds with a single line of code.
Stars: ✭ 995 (+689.68%)
Mutual labels:  xcode, tvos, cocoapods
Articles Zh Hans
Articles for NSHipster.cn
Stars: ✭ 113 (-10.32%)
Mutual labels:  xcode, tvos, watchos
Guitar
A Cross-Platform String and Regular Expression Library written in Swift.
Stars: ✭ 641 (+408.73%)
Mutual labels:  tvos, watchos, cocoapods
R.swift
Strong typed, autocompleted resources like images, fonts and segues in Swift projects
Stars: ✭ 8,419 (+6581.75%)
Mutual labels:  xcode, tvos, watchos
Articles
Articles for NSHipster.com
Stars: ✭ 1,166 (+825.4%)
Mutual labels:  xcode, tvos, watchos
Apprepositorytemplate
The easiest way to start a new application project without any manual configuration
Stars: ✭ 24 (-80.95%)
Mutual labels:  xcode, tvos, watchos
Swiftui
A collaborative list of awesome SwiftUI resources. Feel free to contribute!
Stars: ✭ 774 (+514.29%)
Mutual labels:  xcode, tvos, watchos
Open Source Ios Apps
📱 Collaborative List of Open-Source iOS Apps
Stars: ✭ 28,826 (+22777.78%)
Mutual labels:  tvos, watchos, cocoapods
Cirrus
☁️ Simple CloudKit sync for Codable Swift models
Stars: ✭ 65 (-48.41%)
Mutual labels:  cloudkit, icloud, watchos
Predicateflow
Write amazing, strong-typed and easy-to-read NSPredicate.
Stars: ✭ 98 (-22.22%)
Mutual labels:  tvos, watchos, cocoapods
Swiftframeworktemplate
A template for new Swift iOS / macOS / tvOS / watchOS Framework project ready with travis-ci, cocoapods, Carthage, SwiftPM and a Readme file
Stars: ✭ 527 (+318.25%)
Mutual labels:  tvos, watchos, cocoapods
Swiftyattributes
A Swifty API for attributed strings
Stars: ✭ 1,303 (+934.13%)
Mutual labels:  tvos, watchos, cocoapods
Surmagic
🚀 The better way to deal with Binary Frameworks on iOS, Mac Catalyst, tvOS, macOS, and watchOS. Create XCFrameworks with ease.
Stars: ✭ 119 (-5.56%)
Mutual labels:  xcode, tvos, watchos

SPM compatible Carthage compatible Build Status CocoaPods Compatible Platform Twitter

CloudKitGDPR

Swift framework for allowing users to manage data stored in iCloud. This project is based on the sample code provided by Apple.

Requirements

  • iOS 8.0+ / macOS 10.10+ / tvOS 9.0+ / watchOS 3.0+
  • Xcode 10.2+
  • Swift 5.0+

Installation

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 CloudKitGDPR into your Xcode project using Carthage, specify it in your Cartfile:

github "arturgrigor/CloudKitGDPR" ~> 2.1

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

❗️ Please note that since version 1.2 this is a Static Framework and it does not need to be included in the carthage copy-frameworks Build Phase. For more information please consult the Build static frameworks to speed up your app’s launch times section.

CocoaPods

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

$ gem install cocoapods

CocoaPods 1.1.0+ is required.

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

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

target '<Your Target Name>' do
    pod 'CloudKitGDPR', '~> 2.1'
end

Then, run the following command:

$ pod install

Swift Package Manager

The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler. It is in early development, but CloudKitGDPR does support its use on supported platforms.

Once you have your Swift package set up, adding CloudKitGDPR as a dependency is as easy as adding it to the dependencies value of your Package.swift.

dependencies: [
    .Package(url: "https://github.com/arturgrigor/CloudKitGDPR.git", majorVersion: 2)
]

Usage

Create the instance

import CloudKitGDPR

let defaultContainer = CKContainer.default()
let documents = CKContainer(identifier: "iCloud.com.example.myexampleapp.documents")
let settings = CKContainer(identifier: "iCloud.com.example.myexampleapp.settings")

let metadata: GDPR.RecordTypesByContainer = [
  defaultContainer: ["log", "verboseLog"],
  documents: ["textDocument", "spreadsheet"],
  settings: ["preference", "profile"]
]

let maping: GDPR.ContainerNameMapping = [
  defaultContainer: "default",
  documents: "docs",
  settings: "settings"
]

let gdpr = GDPR(metadata: metadata, containerNameMapping: maping)

Export Data

Export all user's private data as JSON files.

gdpr.exportData(usingTransformer: JSONDataTransformer.default) { result in
  switch result {
    case .failure(let error):
      print("GDPR export data error: \(error)")

    case .success(let value):
      print("User's private data: \(value)")
  }
}

Supported transformers

  • ZeroDataTransformer: This will give you the CloudKit records directly without any other transformation.
  • CSVDataTransformer: This will give you a list of CSV files.
  • JSONDataTransformer: This will give you a list of JSON files.

Delete All Data

gdpr.deleteData { result in
  switch result {
    case .failure(let error):
      print("GDPR delete data error: \(error)")

    case .success(_):
      // TODO: Maybe cleanup the local data too
      print("All user's private data deleted.")
    }
}

Advanced Usage

iOS

Export data as JSON files in a ZIP archive using the ZIPFoundation framework.

import CloudKitGDPR
import ZIPFoundation

lazy var applicationCachesDirectory: URL = {
  let urls = FileManager.default.urls(for: .cachesDirectory, in: .userDomainMask)
  return urls[urls.count-1]
}()

gdpr.exportData(usingTransformer: JSONDataTransformer.default) { result in
  switch result {
    case .failure(let error):
      print("GDPR export data error: \(error)")

    case .success(let value):
      DispatchQueue.global(qos: .background).async {
        let url = self.applicationCachesDirectory.appendingPathComponent("data.zip")
        let archive = Archive(url: url, accessMode: .create)
        for (fileName, csvContents) in value {
          let data = Data(bytes: Array(csvContents.utf8))
          try? archive?.addEntry(with: fileName, type: .file, uncompressedSize: UInt32(data.count), provider: { data[$0..<$0+$1] })
        }

        DispatchQueue.main.async {
          let viewController = UIActivityViewController(activityItems: [url], applicationActivities: [])
          viewController.popoverPresentationController?.sourceView = self.exportDataCell
          viewController.completionWithItemsHandler = { _, _, _, _ in
            try? FileManager.default.removeItem(at: url)
          }

          self.present(viewController, animated: true, completion: nil)
        }
      }
  }
}

Notes

iOS Demo Prerequisites

  • Change the identifier for the defaultContainer in the GDPR+App.swift file to one that's accessible to you.
  • Replace the "SomeRecordType" record type in the same file with one that's actually used in that container.
  • Use the same container identifier for the com.apple.developer.icloud-container-identifiers key in the Demo.entitlements file.

Contact

Let me know if you're using or enjoying this product.

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