When does iOS clean the local app ./tmp directorie

2019-06-16 17:53发布

问题:

When does iOS clean the local app ./tmp directory?

Note that this is not a dupe of this question. I'm asking about the app specific temporary folder, not the system wide one.

You can use iExplorer to have a look at ./tmp directories on non-jailbroken phones.

(Note: I'm asking this out of curiosity only. I kind of suspect that these never get deleted unless you restore your phone from a backup or reinstall that particular app. But obviously you cannot count on that for semi-permanently storing cached files.)

回答1:

According to the documentation, it could be any time, if the app is not executing:

The system may also purge lingering files from this directory when your app is not running.

It's logical to assume if a) your app is not running; and b) your device is running low on storage, then it's highly likely the system will, at some point, purge the contents of <Application_Home>/tmp/.

It's also worth noting that the documentation states:

Your app should remove files from this directory when it determines they are no longer needed.

The emphasis here being on the app developer to do their own housekeeping and not leave it for the OS to tidy up after them.