Unity-Technologies/UnityCsReference · error · ArgumentException
Platform name '{0}' not supported. Supported platform names:
Error message
Platform name '{0}' not supported.
Supported platform names:
{1}
What it means
Thrown by CustomScriptAssembly.GetPlatformFromName (CustomScriptAssembly.cs:696, ArgumentException) when none of the entries in the static Platforms list match the requested platform name (case-insensitive). The message lists every supported platform name so the developer can pick a valid one. This is reached when resolving names from an asmdef's include/excludePlatforms arrays that were not already rejected as deprecated or renamed.
Source
Thrown at Editor/Mono/Scripting/ScriptCompilation/CustomScriptAssembly.cs:696
foreach(var platformName in RenamedPlatforms)
if (string.Equals(platformName, name, System.StringComparison.OrdinalIgnoreCase))
return true;
return false;
}
public static CustomScriptAssemblyPlatform GetPlatformFromName(string name)
{
foreach (var platform in Platforms)
if (string.Equals(platform.Name, name, System.StringComparison.OrdinalIgnoreCase))
return platform;
var platformNames = Platforms.ConvertAll(p => string.Format("\"{0}\"", p.Name));
platformNames.Sort();
var platformsString = string.Join(",\n", platformNames);
throw new System.ArgumentException(string.Format("Platform name '{0}' not supported.\nSupported platform names:\n{1}\n", name, platformsString));
}
public static CustomScriptAssemblyPlatform GetPlatformFromBuildTarget(BuildTarget buildTarget)
{
foreach (var platform in Platforms)
if (platform.BuildTarget == buildTarget)
return platform;
throw new System.ArgumentException(string.Format("No CustomScriptAssemblyPlatform setup for BuildTarget '{0}'", buildTarget));
}
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
return Equals((CustomScriptAssembly) obj);
}View on GitHub (pinned to 225b0fbdb5)
Solutions
- Read the supported platform names printed in the error message and replace the invalid entry with the exact string shown (matching is case-insensitive but the spelling must match).
- If the platform was renamed, check RenamedPlatforms / DeprecatedPlatforms handling and use the current canonical name (e.g. "iPhone" -> "iOS").
- If the platform module is genuinely absent from your editor install, install the platform module or remove the entry.
Example fix
// before (.asmdef) "includePlatforms": ["iPhone"] // after "includePlatforms": ["iOS"]
Defensive patterns
Strategy: validation
Validate before calling
// Validate platform names against the editor's supported set before writing an asmdef
var supported = new HashSet<string>(
UnityEditor.Compilation.CompilationPipeline.GetAssemblyDefinitionPlatforms()
.Select(p => p.Name), StringComparer.OrdinalIgnoreCase);
foreach (var p in (data.includePlatforms ?? Array.Empty<string>()).Concat(data.excludePlatforms ?? Array.Empty<string>()))
if (!supported.Contains(p))
throw new InvalidOperationException($"Unsupported platform name '{p}'. Valid: {string.Join(", ", supported.OrderBy(x => x))}"); Prevention
- Pick platform names from the Inspector dropdown rather than hand-typing them.
- After a Unity upgrade, scan asmdefs for platform names that may have been renamed/removed.
- Treat platform-name lists as version-specific; do not assume a name is stable across major versions.
When it happens
Trigger: An asmdef lists a platform name that is not recognized by the installed editor build, e.g. "iPhone" (legacy) after Unity renamed it, or "WebGL" spelled "Webgl", or a platform whose module is not installed.
Common situations: Upgrading a project across Unity versions where a platform was renamed or removed. Sharing an asmdef authored on an editor build that includes a platform the current install lacks. Old tutorials using obsolete platform identifiers.
Related errors
- Both 'excludePlatforms' and 'includePlatforms' are set.
- Invalid Define Constraint: "{DefineConstraints[i]}" at line
- Assembly has duplicate references: {duplicateRefsString}
- Folder '{loadedCustomScriptAssemblyReference.PathPrefix}' co
- Assembly cannot be have reserved name '{loadedCustomScriptAs
AI-assisted analysis of Unity-Technologies/UnityCsReference@225b0fbdb5 (2026-08-13).
Data as JSON: /api/errors/b9b77a16b49966fa.
Report an issue: GitHub.