I try to connect my app with CloudKit. All setting was selected.When I start the App on iPhone 14 simulator the following errors was shown:
class CloudKitCategory : ObservableObject {
@Published var isSignedInToiCloud: Bool = false
@Published var error : String = ""
init() {
getCloudStatus()
}
private func getCloudStatus() {
CKContainer.default().accountStatus { [weak self] returnedStatus, returnedError in
DispatchQueue.main.async {
switch(returnedStatus) {
case .available:
self?.isSignedInToiCloud = true
break
case .noAccount:
self?.error = CloudKitError.iCloudAccountNotFound.localizedDescription
break
case .couldNotDetermine:
self?.error = CloudKitError.iCloudAccountNotDeterminated.localizedDescription
break
case .restricted:
self?.error = CloudKitError.iCloudAccountRestricted.localizedDescription
break
default:
self?.error = CloudKitError.iCloudAccountUnknown.rawValue
break
}
}
}
}
enum CloudKitError: String, LocalizedError {
case iCloudAccountNotFound
case iCloudAccountNotDeterminated
case iCloudAccountRestricted
case iCloudAccountUnknown
}
}
struct CloudKit: View {
@StateObject private var vm = CloudKitCategory()
var body: some View {
Text("IS SIGNED IN: \(vm.isSignedInToiCloud.description.uppercased())")
Text(vm.error)
}
}
In simulator I have already sign-in.
The log: 2022-10-02 12:25:06.233469+0200 ABCBudget[12806:256090] [CK] Invalid value of "(null)" for entitlement "application-identifier" or "com.apple.developer.associated-application-identifier" on process "ABCBudget(12806)". We expect TEAMID.BUNDLEID, and insist that TEAMID is exactly 10 characters long, consisting of [0-9][A-Z]. This is a permanent issue, and access to CloudKit will be denied until this is resolved 2022-10-02 12:25:06.233546+0200 ABCBudget[12806:256090] [CK] Invalid value of "(null)" for entitlement "application-identifier" or "com.apple.developer.associated-application-identifier" on process "ABCBudget". We expect TEAMID.BUNDLEID, and insist that TEAMID is exactly 10 characters long, consisting of [0-9][A-Z]. This is a permanent issue, and access to CloudKit will be denied until this is resolved 2022-10-02 12:25:06.282552+0200 ABCBudget[12806:256090] *** Terminating app due to uncaught exception 'CKException', reason: 'containerIdentifier can not be nil' ... libc++abi: terminating with uncaught exception of type CKException *** Terminating app due to uncaught exception 'CKException', reason: 'containerIdentifier can not be nil' terminating with uncaught exception of type CKException CoreSimulator 857.7 - Device: iPhone 14 (BA464A05-5974-464B-ACD2-A01C4F3DDBF1) - Runtime: iOS 16.0 (20A360) - DeviceType: iPhone 14
was wrong with CKContainer.default() ?