CloudKit Not Saving Records

Hi ..

Im working on CloudKit, I made new iOS project and added a CloudKit Capability, as well as a container, imported it in a View Controller and tried to save data as code below, but nothing is happeing and no data is being saved when I go to the dashboard ?


@IBAction func addReport(_ sender: Any) {
        
        let bugReport = CKRecord(recordType: "NewReport")
        bugReport ["BugName"] = "Bug 1"
        bugReport ["BugDisc"] = "Its a main bug"
        
        let container = CKContainer.default()
        let database = container.publicCloudDatabase
        database.save(bugReport) {(savedRecords, error) in
            
        }
        
    }

So did you find a way to get the right container ?

Actually no, is there a change that the error catching code isnt showing the right message ? cause its showing the bundle identifier as the container that cant be reached ?

Well, the dash was just a display. The error description is effectively iCloud.vision.honest.cloudkitdemo


It may be the way you define container (using default may be the problem).


https://stackoverflow.com/questions/58453521/how-do-i-access-icloud-container-data-from-an-app-with-a-different-bundle-identi

Quoting SO:

If you have selected the correct container in the entitlements, then just make sure when you set your CloudKit Container in code from within My App Feedback that you are specifying the correct one:


let container = CKContainer(identifier: "iCloud.com.myDomain.My-App")

and not either of these:


let container = CKContainer(identifier: "iCloud.com.myDomain.My-App-Feedback")
let container = CKContainer.default() //This should work, but might be using the wrong one


You could confirm which container is being selected by printing it to the console when it gets instantiated.

Im aware about the dash but the 2 names are totally different, now I explicitly choosed the containr same as code you sent me, I got

a different error saying "CREATE operation not permited" screen is in same iCloud Folder if you can have a look please.

--

Thanks Allot

Could you show the code for declaration of container equivalent to:


let container = CKContainer(identifier: "iCloud.com.myDomain.My-App")


should probably be something like this ?

let container = CKContainer(identifier: "iCloud.com.vision.honest.cloudkitdemo")

or

let container = CKContainer(identifier: "iCloud.vision.honest.cloudkitdemo")

code is below


let container = CKContainer(identifier: "iCloud.DemoAmmarSMitooriCloudKit")

And it doesn't work ?


Is it the identifier you declared ?


May have a look here for a detailed tutorial.

h ttps://yalantis.com/blog/work-cloudkit/

No it doesnt work I got the error above, I took the correct name, the identifier name is displayed by the error catching code, I think your code is takeing the identifier name in the error not sure, Ill check the tutorial thanks allot.


Kindest Regards

CloudKit Not Saving Records
 
 
Q