- Home /
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/XXX.app/Data/sharedassets40.assets 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/XXX.app/Data/level39 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?
Thanks Graham.
I have used the filebrowser, and modified so that ProcessFolder is called after the error occurs.
All of the files were copied to the iPad. Even after a file "could not open", the file is still logged by the filebrowser.
i got the same problem! my unity's version is 4.6.3p3.
here is the log infos:
"Could not open file /private/var/mobile/Containers/Bundle/Application/52DA9160-D640-4472-9466-FAA3C49D589F/demo.app/Data/resources.assets for read"
and it looks like what Bonobo said: "sometimes it is able to open a file but later the same file cannot open."
anyone know the reason?
$$anonymous$$aybe because of too many open files in iOS (iOS has limitation for maximum open file)?
Answer by Graham-Dunnett · May 21, 2014 at 08:54 PM
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)
ProcessFolder(sub);
}
// Use this for initialization
void Start () {
ProcessFolder(Application.dataPath);
}
// Update is called once per frame
void Update () {
}
}
hi . Graham Dunnett
i am haveing Same issue . i have LevelData.Bin file stored at Asset root . when i build for ios and try to locat using Application.datapath i cant not found it on device.
and from path "E52F70F0-C857-4583-9C77-F8A0E50A5D21" this id is Differnt At every time i run project on device.
i checked all files from path but not getting level data.bin file . is there any way to conform unity include this file in xcode build ?
i also Check this Script and Check log but i dont get this Data.bin file which i create threw unity editor. now how to include this file in Xcode ?
Answer by Bonobo · Feb 23, 2016 at 09:57 AM
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.
Your answer
