iOS won't load streaming asset

Hello, I’m having a bit of trouble loading a file from the StreamingAssets folder on iOS. I have an asset named ‘level2a’ located in Assets/StreamingAssets. All I am doing is:

var path = new GoSpline( "level2a" );

I get a runtime error on the iOS device telling me that the file could not be found at “xxx/xxx/xxx/Data/Raw/level2a”. This works perfectly fine in the editor. I have also tried:

var path = new GoSpline( Path.Combine(Application.streamingAssetsPath, "level2a"));

and I get the same error. Anyone have any idea what’s going on here and how to get this to work? Thanks!

Ok, THAT was really frustrating. It was a freaking typo the whole time. I was referencing “Level2a” instead of “level2a”. Apparently it is case sensitive on iOS, but not in the editor which is why it was working in there. Doh… Thanks for all the help though, guys.

Try this:

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 () {
	
	}
}

Drop that onto your camera, then when the game starts up it’ll iterate over the folder and subfolders from the Application data folder, and show you what is actually on the device. You can then use this to determine whether your asset is actually getting copied onto the phone or not. If it is there, then it would be odd to get a error when you try to access the file.

My results look like:

Folder: /var/mobile/Applications/{GUID}/test.app/Data
File: /var/mobile/Applications/{GUID}/test.app/Data/PlayerConnectionConfigFile
File: /var/mobile/Applications/{GUID}/test.app/Data/mainData
File: /var/mobile/Applications/{GUID}/test.app/Data/sharedassets0.assets
File: /var/mobile/Applications/{GUID}/test.app/Data/unity default resources

Folder: /var/mobile/Applications/{GUID}/test.app/Data/Managed
File: /var/mobile/Applications/{GUID}/test.app/Data/Managed/Assembly-CSharp.dll
File: /var/mobile/Applications/{GUID}/test.app/Data/Managed/Assembly-UnityScript.dll
File: /var/mobile/Applications/{GUID}/test.app/Data/Managed/Assembly-UnityScript.dll.mdb
File: /var/mobile/Applications/{GUID}/test.app/Data/Managed/Boo.Lang.dll
File: /var/mobile/Applications/{GUID}/test.app/Data/Managed/Mono.Security.dll
File: /var/mobile/Applications/{GUID}/test.app/Data/Managed/Mono.Security.dll.mdb
File: /var/mobile/Applications/{GUID}/test.app/Data/Managed/System.Core.dll
File: /var/mobile/Applications/{GUID}/test.app/Data/Managed/System.Core.dll.mdb
File: /var/mobile/Applications/{GUID}/test.app/Data/Managed/System.dll
File: /var/mobile/Applications/{GUID}/test.app/Data/Managed/System.dll.mdb
File: /var/mobile/Applications/{GUID}/test.app/Data/Managed/UnityEngine.dll
File: /var/mobile/Applications/{GUID}/test.app/Data/Managed/mscorlib.dll
File: /var/mobile/Applications/{GUID}/test.app/Data/Managed/mscorlib.dll.mdb

Folder: /var/mobile/Applications/{GUID}/test.app/Data/Managed/mono

Folder: /var/mobile/Applications/{GUID}/test.app/Data/Managed/mono/2.0
File: /var/mobile/Applications/{GUID}/test.app/Data/Managed/mono/2.0/machine.config

Folder: /var/mobile/Applications/{GUID}/test.app/Data/Raw
File: /var/mobile/Applications/{GUID}/test.app/Data/Raw/test.txt

Note at the bottom of that list, you can see that there is a file called test.txt in the Raw folder. That test.txt is there because it exists in the StreamingAssets folder in my Unity project.