Update: It seems that this isn’t a reliable solution. It can be done in iCloud for Windows, but not for macOS.
Update 2: You can go to Settings → Apple ID → iCloud and disable “Optimise Mac Storage”, if that tradeoff is worth it.
iCloud on macOS has a helpful button labelled “Optimise Mac Storage”. It’s good if you have limited space on your Mac - it’ll copy your Desktop and Documents folders in the cloud and only keep the most recent files on your computer.
It’s also not the brightest. I have an Alfred preferences file which was created in 2013, and I keep it in iCloud to sync across multiple Macs. iCloud keeps deleting the local copy, presumably because it’s an old file. You can force it to download it again by clicking this cloud icon, but it doesn’t learn, and next time it sweeps, it’ll delete it again:
So when you try to use Alfred, it shows this error:
You might think “oh, I’ll just configure iCloud to preserve that folder” but, unlike every other cloud sync product in 2020, it can’t do that.
Turns out, you can get around this by modifying the creation time of the file or folder on the filesystem. Also turns out, the
touch utility can only do modification and access times, so you need something else.
Install the Xcode command-line tools
You’ll need one of the tools in this kit. If you haven’t installed it before:
Follow the prompts.
setfile to modify creation time
Note that the datestamp is in the “backwards” month-first format.
If you’re reading this in the distant future, adjust the timestamp to be recent.