{"id":13338722,"url":"https://github.com/arturgrigor/CloudKitGDPR","last_synced_at":"2025-03-11T10:31:51.474Z","repository":{"id":56906043,"uuid":"131762161","full_name":"arturgrigor/CloudKitGDPR","owner":"arturgrigor","description":"Framework for allowing users to manage data stored in iCloud","archived":false,"fork":false,"pushed_at":"2022-11-02T22:13:15.000Z","size":41,"stargazers_count":136,"open_issues_count":1,"forks_count":4,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-03T02:45:31.613Z","etag":null,"topics":["cloudkit","cocoapods","gdpr","icloud","ios","macos","swift","tvos","watchos","xcode"],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/arturgrigor.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-05-01T20:54:44.000Z","updated_at":"2025-02-11T22:18:12.000Z","dependencies_parsed_at":"2022-08-21T03:20:50.362Z","dependency_job_id":null,"html_url":"https://github.com/arturgrigor/CloudKitGDPR","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arturgrigor%2FCloudKitGDPR","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arturgrigor%2FCloudKitGDPR/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arturgrigor%2FCloudKitGDPR/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arturgrigor%2FCloudKitGDPR/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arturgrigor","download_url":"https://codeload.github.com/arturgrigor/CloudKitGDPR/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243015440,"owners_count":20222082,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cloudkit","cocoapods","gdpr","icloud","ios","macos","swift","tvos","watchos","xcode"],"created_at":"2024-07-29T19:17:08.806Z","updated_at":"2025-03-11T10:31:50.921Z","avatar_url":"https://github.com/arturgrigor.png","language":"Swift","readme":"[![SPM compatible](https://img.shields.io/badge/SPM-compatible-4BC51D.svg?style=flat)](https://swift.org/package-manager/)\n[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n[![Build Status](https://travis-ci.org/arturgrigor/CloudKitGDPR.svg?branch=master)](https://travis-ci.org/arturgrigor/CloudKitGDPR)\n[![CocoaPods Compatible](https://img.shields.io/cocoapods/v/CloudKitGDPR.svg)](https://img.shields.io/cocoapods/v/CloudKitGDPR.svg)\n[![Platform](https://img.shields.io/cocoapods/p/CloudKitGDPR.svg?style=flat)](http://cocoadocs.org/docsets/CloudKitGDPR)\n[![Twitter](https://img.shields.io/badge/twitter-@arturgrigor-blue.svg?style=flat)](http://twitter.com/arturgrigor)\n\n# CloudKitGDPR\n\nSwift framework for allowing users to manage data stored in iCloud. This project is based on the [sample code](https://developer.apple.com/support/allowing-users-to-manage-data) provided by Apple.\n\n## Requirements\n\n- iOS 8.0+ / macOS 10.10+ / tvOS 9.0+ / watchOS 3.0+\n- Xcode 10.2+\n- Swift 5.0+\n\n## Installation\n\n### Carthage\n\n[Carthage](https://github.com/Carthage/Carthage) is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.\n\nYou can install Carthage with [Homebrew](http://brew.sh/) using the following command:\n\n```bash\n$ brew update\n$ brew install carthage\n```\n\nTo integrate CloudKitGDPR into your Xcode project using Carthage, specify it in your `Cartfile`:\n\n```ogdl\ngithub \"arturgrigor/CloudKitGDPR\" ~\u003e 2.1\n```\n\nRun `carthage update` to build the framework and drag the built `CloudKitGDPR.framework` into your Xcode project.\n\n❗️ 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](https://github.com/Carthage/Carthage#carthage-0300-or-higher) section.\n\n### CocoaPods\n\n[CocoaPods](http://cocoapods.org) is a dependency manager for Cocoa projects. You can install it with the following command:\n\n```bash\n$ gem install cocoapods\n```\n\n\u003e CocoaPods 1.1.0+ is required.\n\nTo integrate CloudKitGDPR into your Xcode project using CocoaPods, specify it in your `Podfile`:\n\n```ruby\nsource 'https://github.com/CocoaPods/Specs.git'\nplatform :ios, '10.0'\nuse_frameworks!\n\ntarget '\u003cYour Target Name\u003e' do\n    pod 'CloudKitGDPR', '~\u003e 2.1'\nend\n```\n\nThen, run the following command:\n\n```bash\n$ pod install\n```\n\n### Swift Package Manager\n\nThe [Swift Package Manager](https://swift.org/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.\n\nOnce 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`.\n\n```swift\ndependencies: [\n    .Package(url: \"https://github.com/arturgrigor/CloudKitGDPR.git\", majorVersion: 2)\n]\n```\n\n## Usage\n\n### Create the instance ###\n\n```swift\nimport CloudKitGDPR\n\nlet defaultContainer = CKContainer.default()\nlet documents = CKContainer(identifier: \"iCloud.com.example.myexampleapp.documents\")\nlet settings = CKContainer(identifier: \"iCloud.com.example.myexampleapp.settings\")\n\nlet metadata: GDPR.RecordTypesByContainer = [\n  defaultContainer: [\"log\", \"verboseLog\"],\n  documents: [\"textDocument\", \"spreadsheet\"],\n  settings: [\"preference\", \"profile\"]\n]\n\nlet maping: GDPR.ContainerNameMapping = [\n  defaultContainer: \"default\",\n  documents: \"docs\",\n  settings: \"settings\"\n]\n\nlet gdpr = GDPR(metadata: metadata, containerNameMapping: maping)\n```\n\n### Export Data ###\n\nExport all user's private data as JSON files.\n```swift\ngdpr.exportData(usingTransformer: JSONDataTransformer.default) { result in\n  switch result {\n    case .failure(let error):\n      print(\"GDPR export data error: \\(error)\")\n\n    case .success(let value):\n      print(\"User's private data: \\(value)\")\n  }\n}\n```\n\nSupported transformers\n- `ZeroDataTransformer`: This will give you the CloudKit records directly without any other transformation.\n- `CSVDataTransformer`: This will give you a list of CSV files.\n- `JSONDataTransformer`: This will give you a list of JSON files.\n\n### Delete All Data ###\n\n```swift\ngdpr.deleteData { result in\n  switch result {\n    case .failure(let error):\n      print(\"GDPR delete data error: \\(error)\")\n\n    case .success(_):\n      // TODO: Maybe cleanup the local data too\n      print(\"All user's private data deleted.\")\n    }\n}\n```\n\n## Advanced Usage\n\n### iOS\n\nExport data as JSON files in a ZIP archive using the [ZIPFoundation](https://github.com/weichsel/ZIPFoundation) framework.\n\n```swift\nimport CloudKitGDPR\nimport ZIPFoundation\n\nlazy var applicationCachesDirectory: URL = {\n  let urls = FileManager.default.urls(for: .cachesDirectory, in: .userDomainMask)\n  return urls[urls.count-1]\n}()\n\ngdpr.exportData(usingTransformer: JSONDataTransformer.default) { result in\n  switch result {\n    case .failure(let error):\n      print(\"GDPR export data error: \\(error)\")\n\n    case .success(let value):\n      DispatchQueue.global(qos: .background).async {\n        let url = self.applicationCachesDirectory.appendingPathComponent(\"data.zip\")\n        let archive = Archive(url: url, accessMode: .create)\n        for (fileName, csvContents) in value {\n          let data = Data(bytes: Array(csvContents.utf8))\n          try? archive?.addEntry(with: fileName, type: .file, uncompressedSize: UInt32(data.count), provider: { data[$0..\u003c$0+$1] })\n        }\n\n        DispatchQueue.main.async {\n          let viewController = UIActivityViewController(activityItems: [url], applicationActivities: [])\n          viewController.popoverPresentationController?.sourceView = self.exportDataCell\n          viewController.completionWithItemsHandler = { _, _, _, _ in\n            try? FileManager.default.removeItem(at: url)\n          }\n\n          self.present(viewController, animated: true, completion: nil)\n        }\n      }\n  }\n}\n```\n\n## Notes\n\n### iOS Demo Prerequisites\n- Change the identifier for the `defaultContainer` in the `GDPR+App.swift` file to one that's accessible to you.\n- Replace the `\"SomeRecordType\"` record type in the same file with one that's actually used in that container.\n- Use the same container identifier for the `com.apple.developer.icloud-container-identifiers` key in the `Demo.entitlements` file.\n\n# Contact\n\n- [GitHub](https://github.com/arturgrigor)\n- [Twitter](https://twitter.com/arturgrigor)\n\nLet me know if you're using or enjoying this product.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farturgrigor%2FCloudKitGDPR","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farturgrigor%2FCloudKitGDPR","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farturgrigor%2FCloudKitGDPR/lists"}