Skip to content

build(switch): prepare stubs before batch builds - #2852

Merged
bitsandfoxes merged 1 commit into
mainfrom
jpnurmi/build/switch-stubs
Sep 18, 2026
Merged

bitsandfoxes merged 1 commit into
mainfrom
jpnurmi/build/switch-stubs

Conversation

@jpnurmi

@jpnurmi jpnurmi commented Sep 16, 2026 •

Copy link
Copy Markdown
Collaborator

Fresh Switch integration builds with no-op stubs fail: https://github.com/getsentry/sentry-switch/actions/runs/34956285369/job/104345147727

BuildFailedException: Sentry's Switch no-op stubs in 'Assets/Plugins/Sentry' were out of step with the installed libraries and have been updated. Please trigger the build again.

Fresh integration projects reached BuildPlayer without the Switch no-op stub. Stub setup was deferred through
EditorApplication.delayCall and only created files for the active build target, but the batch build did not select Switch at startup.

The build preprocessor copied the missing stub and then deliberately failed: Unity collects native plugins before preprocessing, so adding one there cannot reliably affect the current build. Starting another CI run with a clean project repeats the same failure.

Select Switch with -buildTarget when launching the integration build. Synchronize stubs directly in OnPostprocessAllAssets after domain reloads or native library changes, when asset operations are safe. This prepares the stub before building and removes it when the real native libraries are imported.

Extracted from #2851 which was abused to confirm the fix -> https://github.com/getsentry/sentry-switch/actions/runs/34956285369/job/104453539781 succeeds

Fresh Switch integration builds with no-op stubs fail with
`BuildFailedException`:

    Sentry's Switch no-op stubs in 'Assets/Plugins/Sentry' were out of
    step with the installed libraries and have been updated. Please
    trigger the build again.

Fresh integration projects reached `BuildPlayer` without the Switch
no-op stub. Stub setup was deferred through
`EditorApplication.delayCall` and only created files for the active
build target, but the batch build did not select Switch at startup.

The build preprocessor copied the missing stub and then deliberately
failed: Unity collects native plugins before preprocessing, so adding
one there cannot reliably affect the current build. Starting another
CI run with a clean project repeats the same failure.

Select Switch with `-buildTarget` when launching the integration build.
Synchronize stubs directly in `OnPostprocessAllAssets` after domain
reloads or native library changes, when asset operations are safe.
This prepares the stub before building and removes it when the real
native libraries are imported.
Comment thread src/Sentry.Unity.Editor/Native/SwitchNativeStub.cs

@bitsandfoxes bitsandfoxes left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for fixing this!

@bitsandfoxes
bitsandfoxes merged commit be1cd8a into main Sep 18, 2026
121 of 122 checks passed
@bitsandfoxes
bitsandfoxes deleted the jpnurmi/build/switch-stubs branch September 18, 2026 13:37
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.

2 participants