Defaults icon indicating copy to clipboard operation
Defaults copied to clipboard

iCloud Settings Sync Issue: New App Installation Overwrites Existing Values with Empty Defaults

Open wyk111wyk opened this issue 6 months ago • 2 comments

Problem Description

When creating settings that sync through iCloud, I encounter the following issue:

  1. Set some values in the app on Device A
  2. Install the app on Device B (new installation)
  3. The new app shows empty default values for the same settings
  4. These empty values overwrite the existing iCloud data
  5. All devices now show empty values instead of the original data

Expected Behavior

  • Wait for iCloud sync to complete before initializing settings
  • Load existing values from iCloud instead of using local defaults
  • Not overwrite existing iCloud data with empty defaults

wyk111wyk avatar May 26 '25 05:05 wyk111wyk

Are your values Equatable? This should already be handled for Equatable values: https://github.com/sindresorhus/Defaults/pull/185

For non-Equatable values, we still need a proper solution.

sindresorhus avatar May 26 '25 12:05 sindresorhus

I think we could add this check: if both local and remote timestamps do not exist, we should abort the synchronization task. It should be suitable for resolving the new app initialization issue.

hank121314 avatar May 26 '25 13:05 hank121314

Yeah, makes sense 👍

sindresorhus avatar Jun 27 '25 12:06 sindresorhus

@wyk111wyk Can you help try out 9.0.4: https://github.com/sindresorhus/Defaults/releases/tag/9.0.4

sindresorhus avatar Aug 30 '25 08:08 sindresorhus