Write to file in Xcode

I’ve got Unity reading and writing to a .txt file fine under the Unity SDK. The .txt file is stored under Streaming Assets and I’ve altered my code so it will be accessed correctly, (ie correct file path), when I run it in Xcode. However I seem to be only able to read the file in the Xcode build. Writing to it is either not happening or is not being saved (I suspect its’s not being saved) so changes to the file are not present when I next load the application.

I’m not entirely sure if I’m going about this the right way by using Streaming Asset. What I would like to do is have a .txt file which stores data and is read and written to between sessions. So I should be able to run this in Xcode and alter the file then have that alteration present when I next start the application. How do I go about doing this?

The problem you have here is that you are trying to write to the bundle; any files that exist within the Unity project that get copied to your iDevice get put into the bundle. The bundle all inside the .app and you’re not able to write to that without invalidating the code signing. Ultimately, what you should be doing is writing to the Documents directory. Use the file you currently have as default save data, say, and make the new file based upon that. If the file doesn’t exist in the Documents directory then create it anew, if it does then load from that.

This code should get you started