- Home /
Persistent data path changes every time a new version of the IOS app is generated
Hi,
We are working on Unity 4.2.2 and Unity 4.3.4 and we are getting an issue with Application.persistentDataPath, when we update/generate/build a new app version the Application.persistentDataPath changes using a new GUID on the path.
In the Application.persistentDataPath documentation (https://docs.unity3d.com/Documentation/ScriptReference/Application-persistentDataPath.html) says "If you keep the same Bundle Identifier in future versions then the app will continue accessing the same location on every update.". But it isn't happening.
This is our test code:
using UnityEngine;
using System.Collections;
public class PersistenDataPathTest : MonoBehaviour
{
void OnGUI()
{
GUI.Button(new Rect(30f,30f,550f,50),Application.persistentDataPath);
}
}
Steps to reproduce this issue:
Create an empty project with an empty scene, create an empty game object and assign a script with the test code.
Set the bundle identifier and the app version (1.0.0)
Generate the Xcode project for IOS.
Run the test app on a device with iOS 7.
Take a screenshot to backup the current Application.persistentDataPath.
Generate a new Xcode project for IOS but this time with the app version in 1.0.1 (just change the version, don't change the anything else).
Update the app in the device (without remove it).
Notice, the Application.persistentDataPath displayed in the GUI button is different to the old one ( the persistent data path that is in the screenshot ).
Is this supposed to happen?
Is there any way to force the "Application.persistentDataPath" to be the same path on each version of the application?
Should we use a different path to save our data (not using Application.persistentDataPath)?
Thank you in advance for your help.
We're seeing the same issue using Xcode 6.1 with Unity 4.5.5. We didn't see the issue using Xcode 5.
Is there any resolution to this?
Answer by walter_dev · Dec 10, 2014 at 03:27 PM
I don't know about iOS 7 but on iOS 8 the Persistent data path changes every time you run the app, you don't have to worry about this, if you store a file in a previous run it will be present in the changed data path. Forcing to be the same every time isn't possible because this is handled by iOS private code.
Your answer
Follow this Question
Related Questions
Download then open image on IOS 0 Answers
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
file saved to iOS persistent directory exists during session but is gone next session 0 Answers
How do you create a subfolder inside persistentDataPath in iOS? 0 Answers
How to download asset bundles and storing it locally in ios 0 Answers