Home > Mobile >  How do I track whether to update a file during install and first run on iOS
How do I track whether to update a file during install and first run on iOS

Time:10-27

I have a folder of files on my mac which gets copied into the app bundle during an install. When the app launches it checks the date of the bundled files and if it is newer than the existing file in user documents folder I delete the existing file in the user documents directory and then copy the new file.

The problem is that during the install the creation data of the file is the install time (it doesn't keep the original file creation date), so every file in the bundle will always be newer than an existing file on the device.

Say I installed the app yesterday at noon and all the files in the user documents directory have a timestamp noon yesterday or later. I updated a file last night at 8:00 p.m. on the mac, but not on the device. How do I set things up so that when I reinstall the app: only that one updated file gets copied to the user documents directory (which means I delete the existing file in the user documents directory and then copy the new file)

Is there a way to keep the original file creation date when copying the file into the bundle. Am I doing it wrong? How do I leave the files alone that didn't change between installs?

CodePudding user response:

You could keep track of files creation date of user documents in some kind of database in user library directory. So each time you install a new version you know when the user file was created.

  • Related