Troubleshooting

Common CloudKit sync issues and solutions for TheCompanyApp.

Not Syncing Across Devices

Symptom

Created company on iPhone, doesn't appear on iPad (same Apple ID).

Causes & Solutions

1. Not Signed In to iCloud

Settings → [Your Name] → iCloud → Ensure signed in

2. iCloud Drive Disabled for App

Settings → [Your Name] → iCloud → TheCompanyApp → Enable toggle

3. Network Issues

  • Check Wi-Fi or cellular connection

  • Try toggling Airplane Mode off/on

  • Wait 1-2 minutes for sync to complete

4. CloudKit Zone Not Created

  • Delete app, reinstall

  • Sign out of iCloud, sign back in

  • Reset sync: See "Reset CloudKit Data" below

5. Check Sync Events Add logging to detect sync failures:

Share Not Received

Symptom

Owner sends share link, participant taps link but nothing happens.

Solutions

1. Check URL Scheme

  • Share URL must start with https://www.icloud.com/share/

  • Ensure universal links enabled in Xcode

2. App Not Installed

  • Participant must have TheCompanyApp installed

  • Safari won't redirect to app otherwise

3. Wrong Apple ID

  • Participant must be signed in to iCloud

  • Cannot accept share without iCloud account

4. Share Already Accepted

  • Check if company already in "Shared With Me" section

  • Company might have synced but UI not refreshed

5. Manual Accept Try programmatic accept:

Duplicate Companies

Symptom

Same company appears multiple times in list.

Causes

1. Accepted Share Multiple Times

  • Each acceptance creates new local record

  • CloudKit de-duplicates on server, local doesn't

2. Local and Shared Copies

  • Owner sees company in Private Store

  • After sharing, it appears in Shared Store duplicate? No - should only be in Private.

  • Participant sees only in Shared Store

Solution

Delete one copy:

Participant Can't Edit

Symptom

Participant sees data but cannot modify.

Solutions

1. Check CKShare Permission Owner must set "Can Edit":

2. Check AccessControl Query AccessControl entity:

3. Network Delay

  • Wait 30 seconds after accepting share

  • Permissions sync may be delayed

Changes Not Syncing to Owner

Symptom

Participant creates order, owner doesn't see it.

Solutions

1. Enlistment Missing Ensure new objects enlisted in share:

2. Owner Polling Shared Database Owner's device must poll both Private and Shared:

  • This is automatic with NSPersistentCloudKitContainer

  • Restart app to force refresh

3. Merge Policy Conflict Check if local changes being overwritten:

Quota Exceeded

Symptom

Error: "iCloud storage full" or CKErrorQuotaExceeded.

Solutions

1. Public vs Private Database

  • TheCompanyApp uses Private/Shared (counts against user's iCloud quota)

  • Public Database has 10 PB free (not used here)

2. User's iCloud Storage Full

User must upgrade plan or delete files.

3. Large Attachments

  • Reduce image sizes (see ImageOptimizer.swift)

  • Delete old dispatch records

  • Archive completed orders

4. Developer Account Exceeded

  • App owner's CloudKit dashboard shows usage

  • Contact Apple if limits reached

Network Errors

CKErrorNetworkUnavailable

Solution: Check internet connection, wait and retry.

CKErrorZoneBusy

Solution: CloudKit throttling. Wait 30-60 seconds, retry.

CKErrorRequestRateLimited

Solution: Too many requests. Implement exponential backoff:

Reset CloudKit Data

Warning: Deletes all CloudKit data. Use only for testing.

Development Environment

  1. Select TheCompanyApp container

  2. Development → Reset Schema and Records

  3. Delete app from device, reinstall

Production Environment

Cannot reset production data. Users must:

  • Delete all companies manually

  • Or delete app, reinstall (local data only)

Enable CloudKit Logging

macOS/iOS Console App:

  1. Connect device to Mac

  2. Open Console.app

  3. Filter by com.apple.coredata.cloudkit

  4. Reproduce issue

  5. Look for CloudKit operation logs

Xcode Arguments:

Logs will appear in Xcode console during sync operations.


Related: Sync States, Conflict Resolution, Share Testing Checklist

Last updated