Enables developers to write code that interacts with CloudKit in targets that don't support the CloudKit Framework directly

Overview

CloudKit Web Services

This package enables developers to write code that interacts with CloudKit in targets that don't support the CloudKit Framework directly (such as App Clips).

Stability

This project is currently undergoing development and is subject to breaking changes. During this development Semantic Versioning will not be followed entirely as long as the package remains under release version 1.0.0.

Develop Branch Status: Swift

Contributing

The goal of this project is to provide developers with easy access to CloudKit where it is not available such as within App Clips. If you find something missing that you'd like to see get added, open up an issue, or if you're comfortable writing framework code, open up a Pull Request.

Requirements

  • An Apple Developer account with access to the CloudKit Console
  • iOS 15.0 or newer

Getting Started

To get started with CloudKit Web Services, first create a CKWSContainer.


// Configuration
let identifier = "iCloud.{your-container-name}"
let token = "{your-token-generated-from-cloudkit-console}"

let container = CKWSContainer(identifier: identifier, token: token, enviornment: .development)

Creating a query request


// Create an operation that queries all records of the "ExampleType"
let queryOperation = CKWSQueryOperation(query: CKWSQuery(recordType: "ExampleType"))

queryOperation.recordMatchedBlock = { recordID, result in 
  switch result {
  case .success(let record):
    // TODO: Do something with the record that was received.
    break
    
  case .failure(let error):
    // TODO: Handle per-record failure, perhaps retry fetching it manually in case an asset failed to download or something like that.
    break
}

queryOperation.queryResultBlock = { result in 
  switch result {
  case .success:
    // TODO: Yay, the operation was successful, now do something. Perhaps reload your awesome UI.
    break
    
  case .failure(let error):
    // TODO: An error happened at the operation level, check the error and decide what to do. Retry might be applicable, or tell the user to connect to internet, etc..
    break
}

container.publicCloudDatabase.add(queryOperation)

Comments
  • Allow changing the container environment at runtime

    Allow changing the container environment at runtime

    It is sometimes useful to be able to use the production environment in a debug build to test something. Currently, the environment is set to .development automatically for debug builds, and to .production for release builds, which I think is a great default, but it would be neat if the user of the library could override that manually if they want to.

    If the idea is to replicate the CloudKit framework more closely, then this change could be provided at compile time with a flag different from DEBUG, which would take the place of the entitlement in the original framework.

    Updated by Eric:

    • [x] Dynamic environment selection via initializer
    • [x] Dynamic environment selection via configuration
    enhancement 
    opened by insidegui 2
  • NOT_FOUND error in Fetch operation should produce unknownItem error

    NOT_FOUND error in Fetch operation should produce unknownItem error

    Match the new iOS 15 per-record error behavior. When a record is not found as presented in the RecordFetchErrorDictionary, produce an 'unknownItem' error.

    bug enhancement 
    opened by edorphy 0
  • Add type safety to the RecordFieldDictionary's type property --> backed by enum

    Add type safety to the RecordFieldDictionary's type property --> backed by enum

    To improve type safety of the RecordFieldDictionary, make the 'type' property an enum

    • [x] Make enum
    • [x] Update decoding
    • [ ] Update encoding

    Support for additional types:

    • [ ] Handle "UNKNOWN_LIST" FB9825479
    • [ ] BYTES
    • [ ] BYTES_LIST

    Test Coverage of RecordFieldDictionary:

    • [x] Single item types
    • [ ] List item types
    enhancement tech debt 
    opened by edorphy 0
  • Consider representing integer as NSNumber so bridge casting to any int or bool behaves like CloudKit does

    Consider representing integer as NSNumber so bridge casting to any int or bool behaves like CloudKit does

    https://developer.apple.com/documentation/foundation/nsnumber https://stackoverflow.com/questions/45610119/swift-casts-bool-to-nsnumber-using-as-operator

    enhancement 
    opened by edorphy 0
  • Investigate UNKNOWN_LIST type returned by fetch

    Investigate UNKNOWN_LIST type returned by fetch

    Found that Apple returned "UNKNOWN_LIST" as a value type in a record. In the portal the type on the offending record was "empty list".

    I saved a string, then deleted the string then console picked up the type as being a list. Seems like an Apple bug I should file feedback for.

    bug 
    opened by edorphy 1
  • Add support for ckWebAuthToken for user authenticated calls

    Add support for ckWebAuthToken for user authenticated calls

    Investigate how to receive the ASWebAuthenticationSession completion within App Clip

    What I've got so far

    1. Call the currentUser
    2. Get the redirect pass it into ASWebAuthenticationSession
    3. Figure out how to hook the session to invoke the app clip user activity or some other mechanism
    enhancement help wanted security 
    opened by edorphy 1
  • Determine if assets should auto download or not

    Determine if assets should auto download or not

    CloudKit Framework auto-downloads asset fields in records. CloudKit JS does not.

    Determine if we want this behavior to auto-download assets (without caching).

    Pros:

    • Easier API
    • Closer to CloudKit behavior

    Cons:

    • No caching support at the API
    • Special handling might be required for different kinds of assets
    • Lightweight models, less network if consumer doesn't use desired keys and gets all by accident

    Other Considerations:

    • AsyncImage takes an optional URL. Procedure
      • onAppear, fetch a record containing an asset
      • then once the asset is received, load the image.
    enhancement question 
    opened by edorphy 0
Owner
Eric Dorphy
Developing apps to be private by design. This is the way. Full stack iOS specialization in micro-location, fitness, and Bluetooth low energy.
Eric Dorphy
šŸ”„ šŸ”„ šŸ”„Support for ORM operation,Customize the PQL syntax for quick queries,Support dynamic query,Secure thread protection mechanism,Support native operation,Support for XML configuration operations,Support compression, backup, porting MySQL, SQL Server operation,Support transaction operations.

?? ?? ??Support for ORM operation,Customize the PQL syntax for quick queries,Support dynamic query,Secure thread protection mechanism,Support native operation,Support for XML configuration operations,Support compression, backup, porting MySQL, SQL Server operation,Support transaction operations.

null 60 Dec 12, 2022
Unrealm is an extension on RealmCocoa, which enables Swift native types to be saved in Realm.

Unrealm enables you to easily store Swift native Classes, Structs and Enums into Realm . Stop inheriting from Object! Go for Protocol-Oriented program

Artur  Mkrtchyan 518 Dec 13, 2022
Simplified access to Apple's CloudKit

EVCloudKitDao Discuss EVCloudKitDao : What is this With Apple CloudKit, you can focus on your client-side app development and let iCloud eliminate the

Edwin Vermeer 632 Dec 29, 2022
Sync Realm Database with CloudKit

IceCream helps you sync Realm Database with CloudKit. It works like magic! Features Realm Database Off-line First Thread Safety Reactive Programming O

Soledad 1.8k Jan 6, 2023
This is the BlurrMC social media platform for iOS hosted on Apple's CloudKit.

BlurrMC for iOS This is the BlurrMC social media platform for IOS! WOOOOOOO! On this version of the social media platform, you have the full featured

BlurrMC 0 Nov 4, 2021
iForage helps foragers to track and manage foraging spots around them using CloudKit

iForage CloudKit Preface To expand on what I've created here: https://github.com/LynchConnor/iForage, I initially developed the app using Firebase. Th

Connor Lynch 3 Jul 14, 2022
CoreDataCloudKitShare - Learn how to use Core Data CloudKit

Sharing Core Data Objects Between iCloud Users Implement the flow to share data

null 3 Feb 10, 2022
CloudKit, Appleā€™s remote data storage service, provides a possibility to store app data using usersā€™ iCloud accounts as a back-end storage service.

CloudKit, Appleā€™s remote data storage service, provides a possibility to store app data using usersā€™ iCloud accounts as a back-end storage service. He

Yalantis 252 Nov 4, 2022
CodableCloudKit allows you to easily save and retrieve Codable objects to iCloud Database (CloudKit)

CodableCloudKit CodableCloudKit allows you to easily save and retrieve Codable objects to iCloud Database (CloudKit) Features ā„¹ļø Add CodableCloudKit f

Laurent Grondin 65 Oct 23, 2022
ReadWriteLock - Swift Implementation of a standard Read/Write lock.

ReadWriteLock A Swift implementation of a Read/Write lock. I'm really amazed that the Swift Standard Library (nor the Objective-C standard library) ha

Galen Rhodes 1 Mar 1, 2022
YapDB is a collection/key/value store with a plugin architecture. It's built atop sqlite, for Swift & objective-c developers.

YapDatabase is a collection/key/value store and so much more. It's built atop sqlite, for Swift & Objective-C developers, targeting macOS, iOS, tvOS &

Yap Studios 3.3k Dec 29, 2022
A Library for iOS developers to check newer version of app from the app store

swift-app-update-checker A very simple solution check new version of your application is available on store or not. Example To run the example project

wajeehulhassan 6 May 13, 2022
Modern interface to UserDefaults + Codable support

Default Modern interface to UserDefaults + Codable support What is Default? Default is a library that extends what UserDefaults can do by providing ex

Nicholas Maccharoli 475 Dec 20, 2022
A Swift wrapper for system shell over posix_spawn with search path and env support.

AuxiliaryExecute A Swift wrapper for system shell over posix_spawn with search path and env support. Usage import AuxiliaryExecute AuxiliaryExecute.l

Lakr Aream 11 Sep 13, 2022
URL query encoder with OpenAPI serialization options support

URLQueryEncoder A customizable Swift Encoder that encodes instances of data type

Alexander Grebenyuk 31 Nov 30, 2022
AppCodableStorage - Extends `@AppStorage` in SwiftUI to support any Codable object

AppCodableStorage Extends @AppStorage in SwiftUI to support any Codable object.

Andrew Pouliot 19 Nov 25, 2022
Store and retrieve Codable objects to various persistence layers, in a couple lines of code!

tl;dr You love Swift's Codable protocol and use it everywhere, who doesn't! Here is an easy and very light way to store and retrieve Codable objects t

null 149 Dec 15, 2022
Sort import statements in your Swift source code

Sort Swift Imports Sort import statements in your Swift source code. ?? Swift Li

Dariusz Rybicki 2 Dec 19, 2022
āš™ļøĀ A tiny property wrapper for UserDefaults. Only 60 lines of code.

āš™ļø A tiny property wrapper for UserDefaults. Only 60 lines of code. import Persistent extension UserDefaults { // Optional property @Per

Mezhevikin Alexey 6 Sep 28, 2022