Skip to content

feat(switch2): add Nintendo Switch 2 support - #2834

Open
bitsandfoxes wants to merge 3 commits into
mainfrom
feat/switch2-support
Open

feat(switch2): add Nintendo Switch 2 support#2834
bitsandfoxes wants to merge 3 commits into
mainfrom
feat/switch2-support

Conversation

@bitsandfoxes

@bitsandfoxes bitsandfoxes commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Brings up Nintendo Switch 2 by routing it through the existing Switch implementation rather than duplicating it.

What

  • Bundle UNITY_SWITCH2 into SENTRY_NATIVE_SWITCH as well.
  • Flip from platform-include to platform-exclude so old Unity versions without the target don't break.
  • IsNativeSupportEnabled maps the platform to SwitchNativeSupportEnabled, Switch 2 shares the option.
  • The existing Switch native assembly and the existing stub are both shipped to Switch 2 via their plugin metadata.
  • SwitchNativePluginBuildPreProcess now runs for both targets, resolves required libraries per platform (Assets/Plugins/Sentry/{Switch,Switch2}/), and toggles stub compatibility for whichever target is building.

Why

Before the IsNativeSupportEnabled mapping, SentryNativeSwitch.Configure was reached but bailed out of immediately:

Sentry: (Debug) Native support is disabled for 'Switch2'.

The switch expression had no Switch2 case, so it fell through to the default and returned false. Native support could never initialize regardless of how the project was configured. After the fix the full sequence runs — temporary storage mounts, the native SDK initializes, and scope sync starts syncing breadcrumbs, user and trace.

No duplicated assembly or stub

Both are gated by plugin metadata, which is what decides where they ship. Both utilize the same stub in case of no native SDK being found.

Matching by name

RuntimePlatform.Switch2 and BuildTarget.Switch2 only exist in Unity 6000.3 and newer. So instead of relying on the enum being preset we do a comparison by name for Switch2 instead.

Verified on a Switch 2 devkit

Native initialization completes and scope sync is live.

Recognise the platform and route it through the existing Switch implementation:
UNITY_SWITCH2 defines SENTRY_NATIVE_SWITCH2, which selects SentryNativeSwitch as
the platform configuration, and both assembly definitions now include Switch 2 so
the runtime code ships to it. Switch 2 shares SwitchNativeSupportEnabled rather
than introducing a second option, since it shares the implementation.

Which platforms an assembly or a stub ships to is decided by its plugin metadata,
so Switch 2 reuses the existing Switch native assembly and the existing stub
rather than duplicating either. The build preprocessor now runs for both targets,
resolves the required libraries per platform, and toggles stub compatibility for
whichever target is being built - the importer tracks that per target, so the two
do not interfere.

RuntimePlatform.Switch2 and BuildTarget.Switch2 only exist in Unity 6000.3 and
newer while the SDK still supports 2021.3, and these assemblies compile against a
single Unity version, so both are matched by name rather than by enum member -
referencing them directly would stop the SDK building against older editors.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ABHTqM37qGAc9iQZcdbdY8
@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor
Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against e9c08ef

Comment thread src/Sentry.Unity.Editor/Native/SwitchNativePluginBuildPreProcess.cs Outdated
Comment thread CHANGELOG.md Outdated

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit c48a310. Configure here.

Comment thread src/Sentry.Unity.Editor/Native/SwitchNativePluginBuildPreProcess.cs Outdated
Comment thread src/Sentry.Unity.Editor/Native/SwitchNativePluginBuildPreProcess.cs Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant