Skip to content

Enable build injection for iOS/Mac Catalyst in maui profile startup #109

@simonrozsival

Description

@simonrozsival

Summary

maui profile startup skips build injection on iOS and Mac Catalyst, requiring users to manually reference Microsoft.Maui.StartupProfiling and call StartupProfilingMarker.Complete(). On Android, this is handled automatically.

Current behavior

In ProfileSessionSetup.cs (line 50-51):

context.BuildInjection = string.Equals(profilePlatform, Platforms.iOS, StringComparison.OrdinalIgnoreCase)
    ? null
    : ProfileCommandBuildInjectionResolver.TryCreateBuildInjection(...);

iOS is unconditionally set to null, which disables:

  1. Auto-injection of StartupProfilingMarker (the AutoInitialize.cs module initializer)
  2. The StartupProfiling.dll assembly reference
  3. Environment variable configuration for EventPipe/PGO

Why it should work

The injected bootstrap code (MauiStartupProfiling.AutoInitialize.cs) is platform-agnostic managed C# — a module initializer that polls for the main page and fires StartupProfilingMarker.Complete(). Nothing in it is Android-specific.

The only Android-specific part is the GenerateMauiStartupProfilingEnvironment MSBuild target, which writes an <AndroidEnvironment> file for runtime-owned EventPipe collection. This target is already conditioned on -android in the .targets file, so it would simply not run on iOS/Mac Catalyst.

Expected behavior

maui profile startup --project MyApp.csproj -f net10.0-ios should auto-inject the startup marker, just like it does for Android. Users should not need to manually reference the package or call Complete().

Scope

  • Remove the iOS platform check at ProfileSessionSetup.cs:50-51
  • Verify build injection works on iOS simulator and Mac Catalyst
  • Consider adding an equivalent environment variable mechanism for iOS if runtime-owned EventPipe collection is needed (analogous to <AndroidEnvironment>)

Metadata

Metadata

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions