Storing AssetBundles on iOs ("do not backup")

We recently created an app that downloads an assetbundle on firsh launch and stores it in Application.persistentDataPath. Apple rejected it because that data is backed up on iCloud.

This is the link they sent: Optimizing Your App’s Data for iCloud Backup | Apple Developer Documentation

In that link, it specifies that data that is required for offline play must be marked “do not backup”. I don’t recall ever seeing this option in Unity, so is there a manual way to do so in Unity?

This would be a problem for anyone using assetbundles as a one time storage and not storing them in the cache.

Before suggesting this, we’ve tried storing the asset bundle in the cache. However, it swelled to 100mb +. Storing it out side the cache let it remain the initial 2.7mb. I’ve also seen some discussion where storing in the cache is not recommended because that is the first place iOs begins to trim down data when it gets low on storage.

Yeesh. Seems tricky.

Found this old forum thread, along with a claim that we’ll be able to set that attribute in the “next” version of Unity. The thread is from 2011, but I don’t recall seeing that feature anywhere. Possible I just missed it.

Also found this StackOverflow thread that asks the same question in a more general context. Sounds like you might be able to write to a folder at Library/Caches and/or Library/Private, if you can reliably find the path for it. They also link to a few options for setting that attribute, but unfortunately none of the links seem immediately applicable to Unity devs.

I wonder if you might be able to use System.IO.File.SetAttributes() here, but I have no idea. I notice FileAttributes.Archive, but we’re probably not lucky enough that it will work seamlessly. :wink:

Good luck solving this one. Please let us know if you find a solution.

I also posted this in the ios development forums where I was pointed to this scripting reference.

Hope it helps!

but basically this:

iPhone.SetNoBackupFlag (pathtofile);