From 0b751b1ed72a49d5f603a32d9e020edffc57a2c2 Mon Sep 17 00:00:00 2001 From: bitsandfoxes Date: Thu, 12 Feb 2026 11:13:52 +0100 Subject: [PATCH 1/3] feat: Allow configuring SwitchNativeSupportEnabled via CLI Add support for `-options.SwitchNativeSupportEnabled` command-line argument in batch mode configuration. This allows CI to disable Switch native support when building without the native SDK, so the build uses stubs instead of erroring about missing files. --- .../SentryEditorWindowInstrumentation.cs | 6 ++++++ test/Scripts.Integration.Test/configure-sentry.ps1 | 14 +++++++++++++- test/Scripts.Integration.Test/integration-test.ps1 | 5 ++++- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/Sentry.Unity.Editor/ConfigurationWindow/SentryEditorWindowInstrumentation.cs b/src/Sentry.Unity.Editor/ConfigurationWindow/SentryEditorWindowInstrumentation.cs index 5be965316..23f44ef80 100644 --- a/src/Sentry.Unity.Editor/ConfigurationWindow/SentryEditorWindowInstrumentation.cs +++ b/src/Sentry.Unity.Editor/ConfigurationWindow/SentryEditorWindowInstrumentation.cs @@ -50,6 +50,12 @@ private static void ConfigureOptions(Dictionary args, [CallerMem OptionsConfigurationItem.SetScript(value); } + if (args.TryGetValue("options.SwitchNativeSupportEnabled", out bool switchNativeSupport)) + { + Debug.LogFormat("{0}: Configuring SwitchNativeSupportEnabled to {1}", functionName, switchNativeSupport); + options.SwitchNativeSupportEnabled = switchNativeSupport; + } + optionsWindow.Close(); Debug.LogFormat("{0}: SUCCESS", functionName); } diff --git a/test/Scripts.Integration.Test/configure-sentry.ps1 b/test/Scripts.Integration.Test/configure-sentry.ps1 index 332716a22..5b3551daf 100644 --- a/test/Scripts.Integration.Test/configure-sentry.ps1 +++ b/test/Scripts.Integration.Test/configure-sentry.ps1 @@ -1,7 +1,8 @@ param( [string] $UnityPath, [string] $Platform = "", - [Switch] $CheckSymbols + [Switch] $CheckSymbols, + [string] $NativeSupportEnabled = "" ) if (-not $Global:NewProjectPathCache) @@ -22,6 +23,17 @@ $unityArgs = @( ` "-cliOptionsScript", "CliConfiguration", ` "-cliOptions.UrlOverride", ($CheckSymbols ? (SymbolServerUrlFor $UnityPath $Platform) : "") ) +if ($NativeSupportEnabled -ne "") { + $optionName = switch ($Platform) { + "Switch" { "SwitchNativeSupportEnabled" } + default { $null } + } + if ($optionName) { + Write-Log "Setting $optionName to $NativeSupportEnabled" + $unityArgs += @("-options.$optionName", $NativeSupportEnabled) + } +} + RunUnityAndExpect $UnityPath "ConfigureSentryOptions" "ConfigureOptions: SUCCESS" $unityArgs diff --git a/test/Scripts.Integration.Test/integration-test.ps1 b/test/Scripts.Integration.Test/integration-test.ps1 index d6c1ddc5a..8c4ce6ba2 100644 --- a/test/Scripts.Integration.Test/integration-test.ps1 +++ b/test/Scripts.Integration.Test/integration-test.ps1 @@ -47,7 +47,10 @@ If (-not(Test-Path -Path "$(GetNewProjectPath)")) { Write-PhaseSuccess "Sentry added" Write-PhaseHeader "Configuring Sentry" - ./test/Scripts.Integration.Test/configure-sentry.ps1 "$UnityPath" -Platform $Platform -CheckSymbols:$CheckSymbols + $nativeSupportEnabled = if ($Platform -eq "Switch") { + if ($NativeSDKPath) { "true" } else { "false" } + } else { "" } + ./test/Scripts.Integration.Test/configure-sentry.ps1 "$UnityPath" -Platform $Platform -CheckSymbols:$CheckSymbols -NativeSupportEnabled $nativeSupportEnabled Write-PhaseSuccess "Sentry configured" } From 19202bfc19d385257a1b6779f1e0fa120fa09fcd Mon Sep 17 00:00:00 2001 From: bitsandfoxes Date: Thu, 12 Feb 2026 13:17:28 +0100 Subject: [PATCH 2/3] Log warning instead of error --- .../SentryEditorWindowInstrumentation.cs | 6 ------ .../Native/SwitchNativePluginBuildPreProcess.cs | 2 +- test/Scripts.Integration.Test/configure-sentry.ps1 | 14 +------------- test/Scripts.Integration.Test/integration-test.ps1 | 5 +---- 4 files changed, 3 insertions(+), 24 deletions(-) diff --git a/src/Sentry.Unity.Editor/ConfigurationWindow/SentryEditorWindowInstrumentation.cs b/src/Sentry.Unity.Editor/ConfigurationWindow/SentryEditorWindowInstrumentation.cs index 23f44ef80..5be965316 100644 --- a/src/Sentry.Unity.Editor/ConfigurationWindow/SentryEditorWindowInstrumentation.cs +++ b/src/Sentry.Unity.Editor/ConfigurationWindow/SentryEditorWindowInstrumentation.cs @@ -50,12 +50,6 @@ private static void ConfigureOptions(Dictionary args, [CallerMem OptionsConfigurationItem.SetScript(value); } - if (args.TryGetValue("options.SwitchNativeSupportEnabled", out bool switchNativeSupport)) - { - Debug.LogFormat("{0}: Configuring SwitchNativeSupportEnabled to {1}", functionName, switchNativeSupport); - options.SwitchNativeSupportEnabled = switchNativeSupport; - } - optionsWindow.Close(); Debug.LogFormat("{0}: SUCCESS", functionName); } diff --git a/src/Sentry.Unity.Editor/Native/SwitchNativePluginBuildPreProcess.cs b/src/Sentry.Unity.Editor/Native/SwitchNativePluginBuildPreProcess.cs index 978e0ce5a..104ec7e92 100644 --- a/src/Sentry.Unity.Editor/Native/SwitchNativePluginBuildPreProcess.cs +++ b/src/Sentry.Unity.Editor/Native/SwitchNativePluginBuildPreProcess.cs @@ -83,7 +83,7 @@ internal static void ConfigureStub(IDiagnosticLogger logger, bool nativeSupportE { if (nativeSupportEnabled) { - logger.LogError( + logger.LogWarning( "Switch native support is enabled but required files are missing:\n{0}\n" + "Build sentry-switch and copy the libraries to the expected locations. " + "See: https://github.com/getsentry/sentry-switch", diff --git a/test/Scripts.Integration.Test/configure-sentry.ps1 b/test/Scripts.Integration.Test/configure-sentry.ps1 index 5b3551daf..332716a22 100644 --- a/test/Scripts.Integration.Test/configure-sentry.ps1 +++ b/test/Scripts.Integration.Test/configure-sentry.ps1 @@ -1,8 +1,7 @@ param( [string] $UnityPath, [string] $Platform = "", - [Switch] $CheckSymbols, - [string] $NativeSupportEnabled = "" + [Switch] $CheckSymbols ) if (-not $Global:NewProjectPathCache) @@ -23,17 +22,6 @@ $unityArgs = @( ` "-cliOptionsScript", "CliConfiguration", ` "-cliOptions.UrlOverride", ($CheckSymbols ? (SymbolServerUrlFor $UnityPath $Platform) : "") ) -if ($NativeSupportEnabled -ne "") { - $optionName = switch ($Platform) { - "Switch" { "SwitchNativeSupportEnabled" } - default { $null } - } - if ($optionName) { - Write-Log "Setting $optionName to $NativeSupportEnabled" - $unityArgs += @("-options.$optionName", $NativeSupportEnabled) - } -} - RunUnityAndExpect $UnityPath "ConfigureSentryOptions" "ConfigureOptions: SUCCESS" $unityArgs diff --git a/test/Scripts.Integration.Test/integration-test.ps1 b/test/Scripts.Integration.Test/integration-test.ps1 index 8c4ce6ba2..d6c1ddc5a 100644 --- a/test/Scripts.Integration.Test/integration-test.ps1 +++ b/test/Scripts.Integration.Test/integration-test.ps1 @@ -47,10 +47,7 @@ If (-not(Test-Path -Path "$(GetNewProjectPath)")) { Write-PhaseSuccess "Sentry added" Write-PhaseHeader "Configuring Sentry" - $nativeSupportEnabled = if ($Platform -eq "Switch") { - if ($NativeSDKPath) { "true" } else { "false" } - } else { "" } - ./test/Scripts.Integration.Test/configure-sentry.ps1 "$UnityPath" -Platform $Platform -CheckSymbols:$CheckSymbols -NativeSupportEnabled $nativeSupportEnabled + ./test/Scripts.Integration.Test/configure-sentry.ps1 "$UnityPath" -Platform $Platform -CheckSymbols:$CheckSymbols Write-PhaseSuccess "Sentry configured" } From a65208f3845df319277ebefdad95936dccdacd09 Mon Sep 17 00:00:00 2001 From: bitsandfoxes Date: Thu, 12 Feb 2026 13:19:19 +0100 Subject: [PATCH 3/3] Updated CHANGELOG.md --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7cb7095bb..f8399f521 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## Unreleased + +### Fixes + +- When targeting Switch, the SDK will no longer cause the build to fail when native libraries are missing but log a warning instead ([#2541](https://github.com/getsentry/sentry-unity/pull/2541)) + ## 4.1.0 ### Deprecations