Skip to content

ci: Run the iOS trim analysis without signing certificates - #5961

Open
ric-oliv wants to merge 1 commit into
mainfrom
ci/ios-trim-analysis
Open

ric-oliv wants to merge 1 commit into
mainfrom
ci/ios-trim-analysis

Conversation

@ric-oliv

@ric-oliv ric-oliv commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

#3841 added the iOS trim step commented out, because publishing for a device asked for signing certificates. It doesn't need them. Trimming and NativeAOT compilation run before code signing, so with EnableCodeSigning=false we get an unsigned app and the same analysis.

I checked it locally with Xcode 27.2 and no signing identity. The publish passes in about a minute from a clean build. It fails with IL2057 when Cocoa-only code uses [SuppressMessage] where it needs [UnconditionalSuppressMessage], and with MT2387 when I revert #5857. The macOS and Android steps miss both.

Follow-up

  • .NET 11 isn't covered yet. The trim app needs a refresh from the .NET 11 MAUI template before it can target net11.0-ios27.2 and net11.0-android37.0. I'm doing that in a separate PR stacked on this one.
  • This PR adds a fourth copy of the Cocoa SDK cache steps to build.yml. Seven jobs across three workflows now compute the key, restore the cache and mostly save it again with the same steps, so I'll move them into a shared action in another PR.

Closes #3852

#skip-changelog

The iOS publish of Sentry.MauiTrimTest was commented out because a device build asked for
signing certificates. Trimming and NativeAOT compilation run before code signing, so publishing
with EnableCodeSigning=false gives the same analysis. The step also skips the Xcode version check,
because the net10.0-ios26 pack only accepts Xcode 26.0 and the runner only has 27.2.

iOS uses TrimMode=partial and treats MT2387 as an error, which catches the launch crash from
#5855 if IsTrimmable ever leaves Sentry.Bindings.Cocoa. The job restores the Cocoa SDK cache
instead of building it from source.

Fixes #3852

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@sentry-junior sentry-junior Bot 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.

Looks good. This solves #3852. The issue assumed the iOS trim publish needed provisioning profiles on CI, and with EnableCodeSigning=false it doesn't, because ILLink and the NativeAOT compile run before signing. That fixes the cause rather than working around it.

A few notes, none blocking:

  • TrimMode=partial on iOS (test/Sentry.MauiTrimTest/Sentry.MauiTrimTest.csproj): the reasoning holds. Sentry and Sentry.Maui are rooted with RootMode="All", and Sentry.Bindings.Cocoa sets IsTrimmable, so all three are still trimmed and analyzed in partial mode, and you also get the MT2387 guard for #5855. The trade-off is that iOS no longer runs the full-mode setup that most NativeAOT apps use. If that ever matters, publishing iOS a second time with -p:TrimMode=full (about a minute) would cover both. Not needed for this PR.
  • The #5855 guard runs on net10.0-ios26 only. #5855 was reported on .NET 11 with the new assembly preparer. You've already said the local revert of #5857 fails with MT2387 here, so the guard works on .NET 10. The .NET 11 follow-up you mentioned closes the rest.
  • ValidateXcodeVersion=false: the root Directory.Build.props already sets this, but this project deliberately doesn't import the root props, so it does need its own copy. 👍
  • Cocoa cache (.github/workflows/build.yml, trim-analysis job): this job only restores the cache and never saves it. It also depends only on build-sentry-native, so right after a Cocoa submodule bump it can start before another job has saved the new key. In that case it builds Cocoa from source (about 15 min) instead of failing. That's fine, just slower on those runs.
  • Tests: the new step is the test. Per the description, it fails on the two real regressions (IL2057 from [SuppressMessage] in Cocoa-only code, and MT2387 with #5857 reverted), and the macOS and Android steps miss both. That's the evidence that matters. The Trim analysis check was still running when I looked, so worth confirming it goes green on the runner image.

This is an automated preliminary review.

@codecov

codecov Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.70%. Comparing base (04c1c8d) to head (d61ea70).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5961   +/-   ##
=======================================
  Coverage   77.70%   77.70%           
=======================================
  Files         535      535           
  Lines       19731    19731           
  Branches     3934     3934           
=======================================
  Hits        15332    15332           
  Misses       3544     3544           
  Partials      855      855           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ric-oliv
ric-oliv marked this pull request as ready for review November 18, 2026 16:30
@github-actions github-actions Bot added the risk: high PR risk score: high label Nov 18, 2026
<!-- Partial trimming leaves assemblies that aren't trimmable untouched. NativeAOT apps that use it crash at launch
when one of ours needs the dynamic registrar, which the iOS SDK reports only as warning MT2387.
See https://github.com/getsentry/sentry-dotnet/issues/5855 -->
<TrimMode>partial</TrimMode>

@jamescrosswell jamescrosswell Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is probably the most contentious bit. I know this is the scenario that resulted in:

However that's not the typical way to build AOT apps and Microsoft themselves warn against it:
https://github.com/dotnet/macios/blob/23eb1c2c9465fe76c810c8a69982c1254161f4b0/dotnet/targets/Xamarin.Shared.Sdk.targets#L524

I think we've got two options:

  1. Either we run the trim tests with both partial and full trimming
  2. Or we only run with full trimming (the most common scenario and the most important one for us to check)

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: high PR risk score: high

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ensure iOS trim tests run in CI

2 participants