Post not yet marked as solved
Hello,
We have a problem and we don't know how to solve it.
Our application uses CloudKit databases.
We can no longer access the CloudKit databases. When we connect to the CloudKit console and select CloudKit Database, we get the message "No Containers".
However, the application continues to work by downloading files located on CloudKit Database.
How can I modify CloudKit Database data?
Post not yet marked as solved
Very simple one. how do I add “create“ permissions for my CloudKit security roles. For some reason “create“ is greyed out when I try to check the box for _creator
Post not yet marked as solved
Is there any tool to automatically migrate data & data structure from Google Firebase to CloudKit?
Post not yet marked as solved
I enabled Advanced Data Protection for my developer account, and this (understandably) broke access to my private records in CloudKit Console.
I disabled Advanced Data Protection but CloudKit Console still cannot connect. In the database popup the "Click here to retry..." option always fails silently.
Does anyone know a workaround?
Post not yet marked as solved
Issue:
I'm experiencing intermittent CloudKit Console 'Internal Error' when performing simple queries on a Private database.
I am experiencing this issue with multiple CloudKit databases.
In all instances, the issue is intermittent.
Steps to Replicate in the CloudKit Console:
Select a Database
Select Records
Select Private Database
Select Custom Zone
Select Record Type
Select Query Records
IF the records populate, click 'Query Records' again until Internal Error occurs.
Expected Results: A list of records
Actual Results: 'Internal Error' (see screenshot below)
Additional Info:
Starting last month, I started receiving CKCloudKit Error 15 when attempting to sync data from a private CloudKit database. My query code has not changed for a few years now with no previous issues. I believe these errors are the 'same' and on the Apple Server side. Is anyone else experiencing this issue?
Any help would be greatly appreciated. Thank you.
Post not yet marked as solved
In our team we have two apps A and B, unfortunately app B was released with iCloud entitlement with selected container ID of the app A. It lead to a problem that our app A displays in iCloud "Manage Storage" list on iOS as app B. Because of that people are loosing all of theirs data as they thing it is app A. App B stores uses only Key-Value storage in iCloud
How can we override that name so it displays A again?
Hello,
I recently started learning Swift and now I'm using Cloudkit to store user information.
I kinda have no idea what I'm doing but I watched this youtube tutorial to save user data and display it in UI instantly with DispatchQueue.main.async but it keeps throwing me an error, saying "No exact matches in call to instance method 'save'"
What I want to do is I want users to save a new record and I want this record to be updated instantly and be displayed on the screen.
How could I fix this?
import Foundation
import CloudKit
enum RecordType:String {
case movie = "Movie"
}
class SavingMovieViewModel : ObservableObject{
private var database :CKDatabase
private var container : CKContainer
@Published var movies: [SavingMovieModel] = []
init(container: CKContainer){
self.container = container
self.database = container.publicCloudDatabase
}
func saveMovie(title:String, director: String, stars:String, review: String){
let record = CKRecord(recordType: RecordType.movie.rawValue)
let movie = Movie(theTitle: title, theDirector: director, theStars: stars, theReview: review)
record.setValuesForKeys(movie.toDictionary())
// saving
self.database.save(record) { newRecord, error in. //<-- here is where the error is :(
if let error = error{
print(error)
}
else{
if let newRecord = newRecord{ //<-- this bit is the problem. i need the new record added to be displayed instantly
if let movie = Movie.fromRecord(newRecord){
DispatchQueue.main.async {
self.movies.append(SavingMovieModel(Movie: movie))
}
}
}
}
}
}
func whatMovies(){
//creating an array of movies
var movies: [Movie] = []
let query = CKQuery(recordType: RecordType.movie.rawValue, predicate: NSPredicate(value: true))
database.fetch(withQuery: query) { result in
switch result{
case.success(let result):
result.matchResults.compactMap{$0.1}
.forEach{
switch $0 {
case.success(let record):
if let movie = Movie.fromRecord(record){
movies.append(movie)
}
case.failure(let error):
print(error)
}
}
DispatchQueue.main.async {
self.movies = movies.map(SavingMovieModel.init)
}
case.failure(let error):
print(error)
}
}
}
}
struct SavingMovieModel{
let movie: Movie
var movieId :CKRecord.ID?{
movie.movieId
}
var title:String{
movie.title
}
var director:String{
movie.director
}
var stars:String{
movie.stars
}
var review:String{
movie.review
}
}
This is the Movie struct for Movie objects
import Foundation
import CloudKit
struct Movie{
var movieId: CKRecord.ID?
var title:String
var director:String
var stars:String
var review:String
init(movieId: CKRecord.ID? = nil, theTitle:String, theDirector:String, theStars:String, theReview:String){
self.title = theTitle
self.director = theDirector
self.stars = theStars
self.review = theReview
self.movieId = movieId
}
func toDictionary() -> [String:Any]{
return ["title": title, "director" :director, "stars":stars, "review": review]
}
static func fromRecord(_ record :CKRecord) -> Movie? {
guard let title = record.value(forKey:"title") as? String, let director = record.value(forKey:"director") as? String, let stars = record.value(forKey:"stars") as? String, let review = record.value(forKey:"review") as? String
else{
return nil
}
return Movie(movieId: record.recordID, theTitle: title, theDirector: director, theStars: stars, theReview: review)
}
}
Post not yet marked as solved
My App is in the App Store, and synced well between iOS devices with the same iCloud account. But after adding a new attribute to an entity 2 weeks ago, the CloudKit stopped syncing.
I checked the Cloudkit console, and can't find the new attribute there! I don't know Why. Actually this attribute already works well in the newest version of my App downloaded form App store.
Then I chose to deploy schema changes, but there are no changes to deploy!
So how to deploy the new change? and how to make the iCloud syncing work again?
Thanks!
Post not yet marked as solved
Hello, I'm new to iOS development and I need help for working with CloudKit.
I have an application that allows me to add, delete and display information stored in a CloudKit container.
When I try to add a new record, this one can be visible into my CloudKit Console but if don't switch to a other view and back to my view (with my list of records) the record isn't displayed.
How can I update my list to reflect directly the new record add to my container ?
This is my code with split into different files (in attachment)
Sets : define my record struct
SetsView: list of my records
AddSetView: add new records
AddSetView-ViewModel : view model with my add function
SetsView-ViewModel: view model with my fetch function
Add function :
func add() async throws {
var newSet = set
newSet.name = name
newSet.code = code
newSet.releaseDate = releaseDate
newSet.numberOfCards = numberOfCards
let record = try await db.save(newSet.set)
guard let set = Set(record: record) else { return }
setsDictionary[set.id!] = set
print("Set added")
}
Fetch function :
func fetchSets() async throws {
let query = CKQuery(recordType: SetRecordKeys.type.rawValue, predicate: NSPredicate(value: true))
query.sortDescriptors = [NSSortDescriptor(key: "name", ascending: false)]
let result = try await db.records(matching: query) // récupère les données qui correspondent aux critères
let records = result.matchResults.compactMap { try? $0.1.get() } // Récupère les records
sets.removeAll()
records.forEach { record in
sets.append(Set(record: record)!)
}
print("Sets fetched")
print(sets)
}
Set.txt
SetsView.txt
AddSetView.txt
AddSetView-ViewModel.txt
SetsView-ViewModel.txt
I try to add some print to figure out what's going on, but I don't understand.
This is the console log for this scenario : open app without any data into the container > add a new record
First, the fetch function is executed but there is no data into the container (it's logic)
Second I add a new record (Set) :
Into the CloudKit console the new Set is visible
So for refresh my view with this record I need to re-call the fetch function. I tried many things but nothing works.
Even if the fetch function is called, the new record is not retrieved. Do you have any idea how to solve this problem?
Thanks for your help.
Post not yet marked as solved
I only used cloudkit private database in my application but the telemetry data shows 244 bytes of public database storage used. When I check my container I don't see any public stored data. I don't understand why this is happening. Can anyone help me?
Post not yet marked as solved
Hello!
I would like my users to save short videos (under 30seconds 1080p) to the public database for all other users to download and view. Is this possible? Will I run into any storage pricing with Apple if I were to pursue this as my application backend?
I am looking at other methods as well (user sharing from their private database) so I can implement video sharing.
Is this feasible and worth pursuing?
Post not yet marked as solved
I've found old forum posts that reference CloudKit pricing based on usage (after exceeding the 'Free' tier). However, it doesn't seem that Apple has any information on any of their website that indicate what that pricing is, or otherwise the limits of a free tier.
The closest I've found to this is on https://developer.apple.com/icloud/cloudkit/ where it says, "Store private data securely in your users’ iCloud accounts for limitless scale as your user base grows, and get up to 1PB of storage for your app’s public data."
So does this mean that the only CloudKit limits now are:
Private data: dependent on individual user's remaining iCloud storage space
Public data: 1 PB
Request count/day: unlimited
Download usage/day: unlimited
I'm being a little sarcastic, but at the same time, if there are still limits and a pricing structure, I'm really scratching my head as to why that doesn't seem to be published anywhere.
Ultimately, I'm trying to find the best, reliable public asset storage with cross-device usage (iOS, tvOS) solution and am weighing CloudKit versus other cloud storage solutions and their costs.
Side note: I'm kinda confused why CloudKit provides public asset storage in the first place, since I thought On-Demand Resources was intended to fill that gap (and ODR does have storage limits too).