Persistent data path changes every time a new version of the IOS app is generated


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 (Unity - Scripting API: Application.persistentDataPath) 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:

  1. Create an empty project with an empty scene, create an empty game object and assign a script with the test code.

  2. Set the bundle identifier and the app version (1.0.0)

  3. Generate the Xcode project for IOS.

  4. Run the test app on a device with iOS 7.

  5. Take a screenshot to backup the current Application.persistentDataPath.

  6. 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).

  7. Update the app in the device (without remove it).

  8. 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.

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.