Files sometimes don’t update from the iCloud

Sometimes when I run a script from my iPad I notice that it when it reads a file from the iCloud it doesn’t get the updated file that I have on the iPhone. I’m thinking the downloadFromiCloud might help here but not sure how to get it to work.

This is how I implemented it and it seems to work:

// load json from iCloud Drive
  let fm = FileManager.iCloud()
  let dir = fm.documentsDirectory()
  let path = fm.joinPath(dir, "simpsons.json")
  await fm.downloadFileFromiCloud(path)
  let contents = Data.fromFile(path)
  let episodes = JSON.parse(contents.toRawString())

I had issues with my different devices not seeing updated iCloud files until I opened the Files app on iOS 13.x, but on the iOS 14 betas, this issue went away for me, so there’s hope… :grin:

1 Like

That’s what happens to me too. I even have an action in the Shortcut to open the Files app to make sure that file has downloaded and wait till I return. That is good news if IOS 14 has the iCloud files refresh quicker.


let fm = FileManager.iCloud()
let path = fm.bookmarkedPath("testFM")
await fm.downloadFileFromiCloud(path)
let readTest = fm.readString(path)
log(readTest)

This is my test script. It still doesn’t update the file I amended to on my other device. But if I open the files app on the new device it does update. Maybe a bug.