iOS build cannot open files in Data folder

In iOS builds, sometimes Unity cannot open files in the Data folder. The problem is inconsistent, sometimes it is able to open a file but later the same file cannot open. Also, it works correctly in the editor and Standalone-Mac builds.

Sometimes it fails to open an asset file, when this happens there are missing textures or prefabs fail to instantiate. The XCode log might look like this:

Could not open file /var/mobile/Applications/E52F70F0-C857-4583-9C77-F8A0E50A5D21/ for read

Sometimes if fails to open a level file, when this happens the app freezes. The XCode log is:

Could not open file /var/mobile/Applications/E52F70F0-C857-4583-9C77-F8A0E50A5D21/ for read

The files do exist when I look for them manually in the build folder. Furthermore, the fact that the app sometimes loads assets/scenes correctly suggests that it is able to find the Data folder.

(Edit: After using the filebrowser posted by Graham, I can confirm that the files were copied to the iOS device. The files that could not open were all logged, even after the error occured.)

Sometimes a file opens normally a few times before the same file is unable to open.

Has anyone encountered a similar problem?

Never heard that problem before. If the files exist in the Data folder in the Xcode project, then it’s possible these files haven’t been correctly copied over to the iOS device when Xcode deploys the app. It’s probably worth dumping out the contents of the Data folder:

using UnityEngine;
using System;
using System.IO;

public class filebrowser : MonoBehaviour {

	void ProcessFolder(string f) {

		Debug.Log("Folder: " + f);
		var txtFiles = Directory.GetFiles(f);
		foreach (string currentFile in txtFiles) {
			Debug.Log("File: " + currentFile);

		string[] subs = Directory.GetDirectories(f);
		foreach(string sub in subs)
	// Use this for initialization
	void Start () {
	// Update is called once per frame
	void Update () {

A few other people have had the same problem. We eventually fixed the issue, but didn’t have the time to get at the root cause of why the problem was occuring, so I can’t explain it precisely.

We had an “Audio Manager” GameObject. The object had lots of children, each child had audio management scripts and each script referenced different audio files. When we added too many children to the GameObject then the problem started to occur. I suspect that if you are having this issue and it still hasn’t been fixed in Unity then you have too many file references in your scene.

@vkajudiya @kunkun2