Building a game for iphone and is not working properly

I just started developing a game for iOS and I have an issue.
The game is working perfect when i’m testing in inside the unity engine but when I build it on my iphone some mechanics are not working, but inside unity they work fine. If this is any iOS development thing that is deferent from android please tell me so I can search more about it.

Please define “not working”, what exactly is or is not happening? Tips for new Unity users

The game it supposed to create a file to save data about the game like the coins of the player and the current stage that the player is, but when I run it through xcode I’m getting the message that the file is not found but when I test it on unity it works fine.

That’s my code that i’m using!!

using UnityEngine;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;

public static class SaveSystem
{
  
    public static void SavePlayer(GameManager player)
    {
        BinaryFormatter formatter = new BinaryFormatter();
        string path = Application.persistentDataPath + "other.doll";
        FileStream stream = new FileStream(path, FileMode.Create);

        PlayerData data = new PlayerData(player);

        formatter.Serialize(stream, data);
        stream.Close();

    }

    public static PlayerData LoadPlayer()
    {
        string path = Application.persistentDataPath + "other.doll";

        if(File.Exists(path))
        {
            BinaryFormatter formatter = new BinaryFormatter();
            FileStream stream = new FileStream(path, FileMode.Open);

            PlayerData data = formatter.Deserialize(stream) as PlayerData;
            stream.Close();

            return data;
        }
        else
        {
            Debug.LogError("Save file not found in " + path);
            return null;
        }
    }

}

What is the debug output, specifically the value for path on iOS

/var/mobile/Containers/Data/Application/11B31953-FABB-4E98-AB0A-3A10D3CFD74D/Documentsplayer.troll

That’s the path that xcode shows me

Yes, I believe you can see the issue from the path, you have a character missing and the file name is not other.doll

I noticed the file name and I changed it, but it didn’t work. What about the character missing?

So here’s a hint. In your message, for the filename it says Documentsplayer.troll , all one word.

Thank you so much, your hint it was all I needed.
My mistake was when I set the name of the file that I wanted to be actually it needs “/”, like this “/player.troll”.

1 Like