Hello, 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: https://developer.apple.com/icloud/documentation/data-storage/ 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.
If the data is marked as do not backup does that mean that if a person downloads an asset bundle for an in app purchase, that itunes will not back it up when it is synced? If so how does a person recover an in app purchase if their phone has to be restored? Thanks, Dan
Well you should offer a way to your user to redownload the inapp for free. I think a "restore" button is now mandatory. http://forums.toucharcade.com/showthread.php?t=138893 But it shouldn't work on consumable purchases.
Just as a clarification, and I realize this might be a dumb question, but: the parameter path of iPhone.SetNoBackupFlag() is the name of the asset bundle file, right? For example: "samplebundle.unity3d" ? The reason I ask is because I can pass that as the parameter for something like Caching.IsVersionCached(url, version), and receive feedback, but I can't check if the iPhone.SetNoBackupFlag(path) is being set correctly on my assetbundle.
@SirGive I just got rejected for this very same reason. So all you did was use the iPhone.SetNoBackupFlag() and it fixed it? What string did you use for the path? I really wish Unity iOS team would give us more info on this; I really don't want to wait a week to test whether this works or not. Any tips or advice would be appreciated. Thank you!
WWW.LoadFromCacheOrDownload always sets "No Backup" flag for cached files. If you are caching files manually and storing them via .NET file API then you should set this flag from your code by calling iPhone.SetNoBackupFlag() and passing full path as an argument.
@Mantas Puida We have a build which has been rejected by Apple. The asset bundle handling code did not change in this update, and we always used www.LoadFromCacheOrDownload. In fact the current live build which was built with 5.3.2p3 works fine (only 250k is being reported in iCloud storage from Settings app). The rejected build was done with Unity 5.3.3p1 which is trying to backup any downloaded asset bundles. The same erroneous behaviour is also present in builds done with 5.3.3p2. Do we need to do something from our side, as from 5.3.3, to flag asset bundles to not be backed up? @JoshPeterson Tagging you since this might be in your realm of IL2CPP team
@xenonmiii Initially, I don't think that this is specifically related to IL2CPP. I'll watch this thread though for more updates and help out if I can.
Hello @xenonmiii, The fix will be coming next week in 5.3.4p1. For now you can modify FileSystem.mm to always set the no backup flag: Code (CSharp): extern "C" int UnityUpdateNoBackupFlag(const char* path, int setFlag) { int result; if (true) // if(setFlag) { u_int8_t b = 1; result = ::setxattr(path, "com.apple.MobileBackup", &b, 1, 0, 0); } else { result = ::removexattr(path, "com.apple.MobileBackup", 0); } return result == 0 ? 1 : 0; } This will make sure any asset bundles that are downloaded are flagged to not be backed up to iCloud. Let me know if you have any issues or further questions. Cheers, Chris edit: I erroneously put 5.3.3p4 as the patch release when I first posted
@xenonmiii, Glad to hear it helps. Let me know if you run into any issues in the meantime. Cheers, Chris
Seems to be fixed in Unity 5.4.0b12 already (havn't checked every single beta version, but b3 and b12).
Hey @mantikor, The fix has made it's way to 5.3. It is still slowly making it's way into 5.4. I will poke this thread once it has landed. Thanks, Chris
Could we know where the problem was ? On 5.3.3 we are downloading asset bundles manually into Application. temporaryCachePath and setting the file with the SetNoBackupFlag function, and still hit the problem with Apple. We are not in the process of changing version and are trying the Filesystem.mm hack falling back to WWW.LoadFromCacheOrDownload , but would like to keep our old system, so the problem was with the SetNoBackupFlag or else where in the WWW class ? Because it has no sense otherwise.
The problem was at cache management logic level in context of how lower level functions handle this flag. Basically when downloaded files were transferred from temp location to cache folder it accidentally was resetting this flag. So hacked version of FileSystem.mm just prevents resetting of this flag as it ignores argument passed to it. It should be ok as temporal solution if you can't update Unity.
My Unity is 5.3.4f1, And I still have this Question. I use www.LoadFromCacheOrDownload to load Asset bundle.
I can confirm that the bug is still present in the most recent 5.3.4f1. I just had an app rejected because of it, and when I use the provided Filesystem.mm hack, my iCloud usage drops from 50Mb to 0.1kb. I am using Application.streamingAssetsPath to access included AssetBundles, which I load using LoadFromCacheOrDownload. I am not downloading anything from the web, and I am not accessing either the temporaryCachePath or persistentDataPath.
5.3.4f1 is not the most recent release. You should look into patch releases: https://unity3d.com/unity/qa/patch-releases. Where most recent update is 5.3.4p5.
I stand corrected. It is working as intended in 5.3.4p5. Thanks. I didn't know that was a place I should look for even newer releases. From a usability perspective, I don't expect to look on the right side of the download page, because I associate those links with older or peripheral resources. I would recommend a sentence below the "Download Installer"; "Found a bug? Check Patch Releases"... or something similar.
I'm dealing with the same rejection issue, due to some data that is stored in the Documents directory which is getting stored or backed up on iCloud which then does not comply with the guidelines. The user can't create any data in my app that should be stored in the Documents directory. I could try to submit it with the hack version in Filesystem.mm...
Hi @FridgeWalaby, The fix for this was released in Unity 5.3.4p1. If you download the patch release, this issue is fixed as @Mantas Puida stated here: Let me know if you run into any issues. Cheers, Chris
As I understand it, you mean that your user doesn't have any option to make anything in your app, correct? If the data you want stored can be recreated by you at any point, then don't save to the Documents folder. The default for the Documents folder is to backup everything to iCloud, unless you set the noBackup flag. You should be saving to Application.temporaryCachePath instead.
Thank you for your replies! @christophergoy I hope the patch does not mess up my unity project. I will get back to you as soon as I installed the patch. It'd be great if that fixes the problem. @TimKofoed Where exactly is the location in Unity to set the directory where data should be stored. Or is this a thing you have to decide manually in Xcode? My project is a game which is a standalone game, so there is no need to store any data outside the app (Documents). Thank you.
@FridgeWalaby If you just make a game in Unity, which doesn't make or save data such as a text file, save file, new levels or assets from a server etc., then you will not be saving anything to the Documents folder at all. As a rule-of-thumb, if you save data which the user made, then save to Documents folder (persistentDataPath), which will be backed up in iCloud. If you save data your app needs, which you can download at any time from a server you own, if it gets deleted locally, then use the Cache folder (temporaryCachePath). When you make a normal project, it will save everything in the project itself, which is the Application.dataPath, which will become read-only when you make and build the project. If you want to manually save something like a save-file or a screenshot, then you might use http://docs.unity3d.com/ScriptReference/Windows.File.WriteAllBytes.html and give it the path (Application.persistentDataPath + "myFolder/" + "screenshot.png") and pass the image along as a byte array. You don't have to worry about where PlayerPrefs saves its data. If you are not manually saving anything to any of the save paths, then just download Unity 5.3.4p5, and it'll be fine. There's no need for any hack or fix. It works the way it's supposed to. You also don't have to do anything in XCode whether you manually save anything or not. http://unity3d.com/unity/qa/patch-releases