I have been trying to load a text file from the mainbundle but I can’t get it to work on an actual iOS device. Here is my procedure when I add files:
- I drag the folder containing my files (located in the same place as the Resource folder, the project “Root” with all the different platform folders) to my project tree and select/check…
- “Copy items to destination group’s folder (if needed)”
- “Create folder references for any added folders”
- “Add to targets”
This creates a blue folder named “Meshes” in the project tree and copies the folder to the proj.ios project folder, all is well so far. When trying to load a text file from the folder I use:
The path returned can be used to read my object without any problems in the simulator. It doesn’t matter if I have “Meshes/” at the beginning or leave it out. When I try to run it on an iOS device the path is set in a similar manner but the file does not open. Seems it can’t find my file for some reason. The resulting path on an iOS device looks like this:
I have opened the target app in finder and looked at its contents to be sure the files are present in the package… and as far as I can tell they are (located in a “Meshes/…” folder inside the package). Should I be using some other method when obtaining the filename?
Any help appreciated, thanks for reading.
I load my text file with fstream, like this:
The if-condition returns true in the simulator and false on my device.