Invalid bundle ID for container

  Kiến thức lập trình

After reviewing a number of similar questions on this forum I’ve decided to post my question as none of the suggestions has worked for me.

I’m new to CloudKit so I’m frustrated over this problem. When I try to post my data to CloudKit I repeatedly get the following error.

Error saving database <CKError 0x600000ca56e0: “Permission Failure” (10/2007); server message = “Invalid bundle ID for container”; op = 707379C7EB959B4F; uuid = 57541664-3A11-42D5-82F3-19831DEB7AC0; container ID = “iCloud.com.mym.ManagingYourMoney”>

Below is the program code I’m using:

        pathToDatabase = databaseFolder + "/" + databaseFileName

        let databaseRecord = CKRecord(recordType: "MYMDatabase")
        print("databaseRecord_on_creation = (databaseRecord)n")

        databaseURL = URL(fileURLWithPath: pathToDatabase)
        print("databaseURL = (databaseURL!)n")

        let dbAsset = CKAsset(fileURL: databaseURL)
        print("dbAsset = (dbAsset)n")
        
        databaseRecord["MYMdb"] = dbAsset
        print("databaseRecord_populated = (databaseRecord)n")

        if let bundleID = Bundle.main.bundleIdentifier {
            print("nBundle.main.bundleIdentifier: (bundleID)n")
        } else {
            print("Bundle ID not found.n")
        }

        let container = CKContainer.default().privateCloudDatabase
        print("container.description = (container)n")




        container.save(databaseRecord) { record, error in
            DispatchQueue.main.async {
                if let error = error {
                    print("Error saving database (error)")
                } else {
                    print("Database successfully saved to Cloud")
                }
            }
        }

The output from the print statements is as follows:

databaseRecord_on_creation = <CKRecord: 0x105505170; recordType=MYMDatabase, recordID=F1E28BC3-0983-4500-89F2-6593666C67C4:(_defaultZone:defaultOwner)>

databaseURL = file:///Users/robertpetruzzelli/Documents/Programming%20Projects/MyProjects/ManagingYourMoney/mym.sqlite

dbAsset = <CKAsset: 0x105509c80; path=/Users/robertpetruzzelli/Documents/Programming Projects/MyProjects/ManagingYourMoney/mym.sqlite, UUID=8EA5D210-133A-4F3A-B8A5-340A51AD723D>

databaseRecord_populated = <CKRecord: 0x105505170; recordType=MYMDatabase, recordID=F1E28BC3-0983-4500-89F2-6593666C67C4:(_defaultZone:defaultOwner), values={
MYMdb = “<CKAsset: 0x105509c80; path=/Users/robertpetruzzelli/Documents/Programming Projects/MyProjects/ManagingYourMoney/mym.sqlite, UUID=8EA5D210-133A-4F3A-B8A5-340A51AD723D>”;
}>

Bundle.main.bundleIdentifier: com.mym.ManagingYourMoney

container.description = <CKDatabase: 0x60000022c880; databaseScope=Private, containerImplementation=<CKContainerImplementation: 0x600003e14600; containerID=<CKContainerID: 0x600000c012c0; containerIdentifier=iCloud.com.mym.ManagingYourMoney, environment=Sandbox>>>

I’ve taken the following steps to correct this problem based on answers I’ve seen here and on reddit..

Unchecked iCloud, cleaned build and rechecked icloud

deleted entitlements file and reset all icloud settings in xcode

created alternate database in developer iCloud

repeatedly cleaned build folder everytime I change something
repeatedly deleted the app from the simulator each time I try something new.

MY XCODE version etc:

XCode 15.4
Build set for iOS 17.5
Compile Language set for Swift 5

Have changed build settings to 16.0 and unspecified for compile language and unspecified for Language and still get this error

My Project Looks like this:

My iCloudKit database looks like this:

i have a training app from Hacking With Swift (Project 33) that works as expected following Paul’s instructions I can’t see where I’ve done anything different, used his sample code modified for my app.

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT