The class defined in script file named 'PrefabId' does not match the file name! in xcode only

I downloaded the Prefab in Prefab addon (Nested prefabs) and it works fine. When I build and run it in xcode for ios I get the above error in the output (only on xcode!).

The class defined in script file named 'PrefabId' does not match the file name!

The file itself looks like this (with censored code because it’s not my class):

using UnityEngine;
using System.Collections;
using System;

[AddComponentMenu("Prefabs/PrefabId")]
public class PrefabId : MonoBehaviour 
{
    [HideInInspector]
    public string id = Guid.NewGuid().ToString();
    [HideInInspector]
    public string assetPath = "";

    void Awake()
    {
       // Code
    }

    public void MoveTo(string newAssetPath)
    {
       // Code
    }

    public void GiveNewId()
    {
       // Code
    }
}

What is the problem?

What's the exact name of the script file. If it is not PrefabId.cs then that's your problem. I assume the case is wrong.

1 Answer

1

“The class defined in script file named ‘PrefabId’ does not match the file name!”

So, you must change the file name to match. Rename it to PrefabId.cs