Unity-Technologies/UnityCsReference · error · NotSupportedException

IL2CPP is not supported for this platform.

Error message

IL2CPP is not supported for this platform.

What it means

This is a default interface member on IScriptingPlatformProperties. The IL2CPPBCLDirectory getter unconditionally throws NotSupportedException because the implementing platform does not provide a CoreCLR/IL2CPP Base Class Library directory. Platforms that actually support IL2CPP are expected to override this property with a real path; the throwing member is the fallback contract for platforms that never will.

Source

Thrown at Editor/Mono/IScriptingPlatformProperties.cs:19

// Unity C# reference source
// Copyright (c) Unity Technologies. For terms of use, see
// https://unity3d.com/legal/licenses/Unity_Reference_Only_License

using System;

namespace UnityEditor;

internal interface IScriptingPlatformProperties : IPlatformProperties
{
    /// <summary>
    /// Points to the CoreCLR BCL Directory
    /// </summary>
    public string CoreCLRBCLDirectory => throw new NotSupportedException("CoreCLR is not supported for this platform.");

    /// <summary>
    /// Points to the IL2CPP directory
    /// </summary>
    public string IL2CPPBCLDirectory => throw new NotSupportedException("IL2CPP is not supported for this platform.");

}

View on GitHub (pinned to 225b0fbdb5)

Solutions

  1. If you own the platform implementation, override IL2CPPBCLDirectory in your IScriptingPlatformProperties implementer to return the real IL2CPP BCL path.
  2. Before accessing, guard with a check that the platform supports IL2CPP (e.g. via BuildPipeline/PlatformSupports scripting backend query) so the property is never hit for unsupported platforms.
  3. If you only need the CoreCLR BCL, use CoreCLRBCLDirectory instead — but note it has the same throwing default and must also be overridden.
  4. Report a bug if a built-in/shipped platform reaches this throw, since shipped platforms are expected to override the member.

Example fix

// before
string dir = props.IL2CPPBCLDirectory; // throws for unsupported platform

// after
string dir = supportsIl2cpp ? props.IL2CPPBCLDirectory : string.Empty;
Defensive patterns

Strategy: validation

Validate before calling

// before touching the property, confirm the platform supports IL2CPP
var props = platform as IScriptingPlatformProperties;
string dir = string.Empty;
// Prefer a scripting-backend support check; only read if supported
if (BuildPipeline.IsFeatureSupported(BuildFeatures.Il2cpp, platformTarget))
    dir = props.IL2CPPBCLDirectory;

Type guard

// narrow to platforms known to override the member
static bool SupportsIl2cppBcl(IScriptingPlatformProperties p)
    => p.GetType().GetMethod("get_IL2CPPBCLDirectory")?.DeclaringType == p.GetType();

Try / catch

try { dir = props.IL2CPPBCLDirectory; }
catch (NotSupportedException) { dir = string.Empty; /* platform has no IL2CPP BCL */ }

Prevention

When it happens

Trigger: Accessing IScriptingPlatformProperties.IL2CPPBCLDirectory (or CoreCLRBCLDirectory) on a platform implementation that did not override it. This happens when editor code queries the scripting backend BCL directory for a platform whose IPlatformProperties/IScriptingPlatformProperties implementation leaves the default member in place.

Common situations: Adding or using a custom/lesser platform module (e.g. a stripped or in-house target) that implements IPlatformProperties but omits the IL2CPP BCL directory override. Switching a project to a platform that intentionally only supports Mono. Editor tooling that iterates all platforms and assumes every one returns a BCL directory.

Related errors


AI-assisted analysis of Unity-Technologies/UnityCsReference@225b0fbdb5 (2026-08-13). Data as JSON: /api/errors/9e6be2f4006de448. Report an issue: GitHub.