Search Unity

AssetBundles not found after updating app. persistentDataPath is changing..?

Discussion in 'iOS and tvOS' started by antifuzz, Sep 30, 2019.

  1. antifuzz

    antifuzz

    Joined:
    Feb 22, 2013
    Posts:
    99
    I have an iOS app that downloads asset bundles from a server and uses some textures within them.

    Everything works fine until I install an updated version of the app over the top of an old one (into which some assetbundles have already been downloaded).

    At this point, all previously downloaded assetbundles can no longer be found, and xcode gives me the error:
    Unable to open archive file: /var/mobile/Containers/Data/Application/50C3C8C7-B5F7-474C-A139-2588B4744520/Documents/myAssetBundle

    I think the problem seems to be that Application.persistentDataPath appears to change when I install a new version of the app.

    According to the docs:
    "When you build the Unity application, a GUID is generated that is based on the Bundle Identifier. This GUID is part of persistentDataPath. If you keep the same Bundle Identifier in future versions, the application keeps accessing the same location on every update.

    However, I can see that the value for GUID changes with each new version of the app that I build.
    For example, here's the paths from two subsequent versions of the app:
    /var/mobile/Containers/Data/Application/3C08E206-135B-4606-89C0-165C2F71FEA3/Documents/myAssetBundle
    /var/mobile/Containers/Data/Application/3521FC70-CE8C-4C9F-98B3-7227591CB876/Documents/myAssetBundle


    I did find this old post on the same subject where a respondent claims that although the path DOES change between versions, any data download there should still be present at the new path. But is this true?? And if that's the case, then why can't I find my AssetBundles in it after updating the app?

    The same project with same code works correctly on Android across updates. I did wonder whether it was something to do with the way xcode builds an app, so I've tried uploading two versions to the iOS App Store and installing them via Testflight, and the same issue is observed. Everything fine on the first install, but it can't find the assetbundles after the update.
     
    Last edited: Sep 30, 2019