Where does Application.persistentDataPath point if build how?

I am using UnityUnity 2020.3 LTS.

When working in Editor on a mac, the Application.persistentDataPath points to ~/Library/Application Support/{company name}/{product name} as per the documentation.
The same is also true if you have done a Development Build.

However, we have noticed that in some builds ~/Library/Application Support/com.{company name}. {product name}.
This build is from a Release Build with Unity 2020.3.9f1 on a different project.

There is no mention in the documentation of this path starting with “com.”.

I was searching for this issue and came across the following issue
Under what conditions does this mean that the path changes?
Because it’s Release Build? Or some other setting? Or was it downloaded from the App Store (ApplicationInstallMode.Store)?

3 Likes

My experiments show that in
Editor it is always ~/Library/Application Support/{company name}/{product name}.
In the built app, ~/Library/Application Support/{company name}/{product name} if it exists.
If it does not exist, it will be ~/Library/Application Support/{bundle id}.

It was not different for each build, and which path was determined at runtime.
Developers using the Unity Editor would have saved data in ~/Library/Application Support/{company name}/{product name}.
If so, Build will also use that path.
You will not notice bugs (such as Steam’s Cloud Build) that only occur when ~/Library/Application Support/{bundle id} is used.

Do I now know how everything behaves?
The documentation is of no help.

2 Likes

Great. This explains the odd package-name-like directory that got used when I changed a project’s company name a while back (also on 2020.3.x). I also get the same behaviour described here.

The relevant documentation page says “The application finds and uses the oldest folder with the required data on your system.” Assuming App Store apps do their own thing actually go and enforce the app bundle path (not testing this myself), they probably never bothered to update the docs about the app bundle path being a candidate for general programs. I will say, “required data” here is an iffy term since it just amounts to the directory existing, and I haven’t been able to get the older unity.* path to work for my project. The docs just seem rather out of date. Also doesn’t explain why Editor doesn’t behave the same. They could either drop the references to old data directories if they aren’t actually used and mention the app bundle path, or just reevaluate everything and make a proper list.

Side note. This is the first I’ve known of CJK Unity docs basically having dark mode. Interesting.

1 Like