fix(switch): prevent stub leaking into supported builds - #2849
Merged
bitsandfoxes merged 9 commits intoSep 14, 2026
Merged
Conversation
sentry-switch is under NDA, so the no-op stubs exist to keep a Switch player linking for anyone who does not have it. They shipped as a plugin in the package, enabled by default, and SwitchNativePluginBuildPreProcess turned them off once the real libraries appeared. That cannot work. A package installed from a registry or a Git URL lives in Library/PackageCache, which Unity treats as immutable, so PluginImporter.SaveAndReimport never reaches disk. The stub stayed enabled and the linker took it in preference to the archive, because an archive is only searched for symbols that are still undefined. Players shipped with no native crash reporting while the build log said the real libraries had been found. The stub is no longer an asset in the package. It sits in Plugins/Switch/SentryStub~, which the AssetDatabase does not import, and SwitchNativeStub copies it into Assets/Plugins/Sentry/<target> while that target's libraries are missing, deleting it once they arrive. That location belongs to the user, so the write lands whatever the package was installed from. Only the active build target gains a copy, so a project that does not build for Switch sees no change in its tree. Removal is not gated that way, because a stale stub shadows the libraries it sits next to. It runs on domain reload and on plugin folder changes, never during a build, so the database has settled long before one starts. SwitchNativePluginBuildPreProcess now only validates, repairing and failing the build rather than mutating assets Unity is already collecting. The copy carries a version stamp in its header, compared against the package's, so an SDK upgrade that adds a binding refreshes every copy. Comparing the stamp rather than the whole file keeps source control's line ending normalization from rewriting it on every domain reload. Also fixes three stubs that returned void where sentry-native returns int: sentry_close, sentry_value_decref and sentry_reinstall_backend. Nothing reads those values, but a caller that did would have read whatever was in the return register. The pinned plugin scope table in test-plugin-platforms.ps1 loses its row for the stub, which is no longer an imported asset.
bitsandfoxes
force-pushed
the
fix/switch-native-stub-linkage
branch
from
September 11, 2026 17:00
bf6ec38 to
195a9c2
Compare
bitsandfoxes
changed the base branch from
main
to
fix/ios-plugin-platform-scope
September 11, 2026 17:00
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 195a9c2. Configure here.
tustanivsky
approved these changes
Sep 14, 2026
bitsandfoxes
merged commit Sep 14, 2026
5ea1a39
into
fix/ios-plugin-platform-scope
60 of 61 checks passed
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

The Issue
Switch and Switch 2 players were linking Sentry's no-op stubs even when the actual
sentry-switchlibraries were installed. This caused the native SDK to "fail" to initialize.The idea was to have the SDK toggle the targeted platforms on the stubs on or off, depending on whether sentry-switch was present. But a package installed from a registry or a Git URL lives in
Library/PackageCache. Unity treats it as basically immutable.What changed
The stub is no longer an asset in the package. It sits in
Plugins/Switch/SentryStub~and gets ignored by the AssetDatabase. When the actual sentry-switch libraries are missingSwitchNativeStubcopies the stub intoAssets/Plugins/Sentry/<target>. It also deletes them when imported. That location is part of the actual project. It's similar to how we treat the proguard file. Similar shape as the iOS bridge, which already copiesSentryNativeBridgeNoOp.minto the generated Xcode project.