Skip to content

Commit e838af9

Browse files
authored
chore: iOS support for Native AOT (#1725)
Context: unoplatform/uno#21066 Context: unoplatform/uno@92676ea Context: https://learn.microsoft.com/en-us/dotnet/maui/deployment/nativeaot?view=net-maui-10.0#publish-using-native-aot MAUI documentation suggests that the `.csproj` should be modified to contain `$(PublishAot)` instead of specifying it on the command-line. In the case of `Chefs`, this doesn't appear to be necessary, but it can be necessary if the project has `@(ProjectReference)`s which can't be built in a trimming environment (e.g. .NET Standard projects). As we *don't* want `$(PublishAot)` to be set by default, introduce a `$(SkiaPublishAot)` "override", a'la unoplatform/uno@92676ea7. `$(PublishAot)` will be true *only if* `$(SkiaPublishAot)`=true. Additionally, it would be useful to install multiple different builds side-by-side. In order for this to work on iOS (and Android), the different builds must have different `$(ApplicationId)`s. Introduce support for the following new MSBuild properties: * `$(ApplicationIdVendorSuffix)`: Value to append to `$(ApplicationId)`, so that separate builds have separate names. * `$(ApplicationTitleVendorSuffix)`: Value to append to `$(ApplicationTitle)`, so that the different builds are distinguishable on the Home Screen. This allows [^0] [^1]: git clean -xdf Chefs{,.Api} dotnet publish -c Release -r ios-arm64 -f net10.0-ios -p:TargetFrameworkOverride=net10.0-ios \ -bl Chefs/Chefs.csproj -p:UseSkiaRendering=true \ -p:ApplicationIdVendorSuffix=.mono "-p:ApplicationTitleVendorSuffix= (Mono)" \ -p:_DeviceName=$UDID "-p:CodesignKey=$CODESIGN_KEY" && cp Chefs/bin/Release/net10.0-ios/ios-arm64/publish/Chefs.ipa ../Chefs-monovm.ipa git clean -xdf Chefs{,.Api} dotnet publish -c Release -r ios-arm64 -f net10.0-ios -p:TargetFrameworkOverride=net10.0-ios \ -bl Chefs/Chefs.csproj -p:UseSkiaRendering=true -p:SkiaPublishAot=true \ -p:ApplicationIdVendorSuffix=.naot "-p:ApplicationTitleVendorSuffix= (NAOT)" \ -p:_DeviceName=$UDID "-p:CodesignKey=$CODESIGN_KEY" && \cp Chefs/bin/Release/net10.0-ios/ios-arm64/publish/Chefs.ipa ../Chefs-naot.ipa Then *both* `Chefs-monovm.ipa` *and* `Chefs-naot.ipa` can be installed *at the same time*, making it easier to do side-by-side comparisons. Finally, add a `Chefs App Finished Launching` message to the end of `App.OnLaunched()` to provide a primitive way to determine app startup times: 1. Launch **Console.app** 2. Select your target device in the Sources panel on the left 3. In the **Search** panel, enter: `Process:Chefs` 4. Click the **▶️Start** button in the toolbar On the target device, launch the app. Back in Console, look for: * The *first* message from Chefs, and * The *first* message containing `Chefs App Finished Launching`. Then subtract the timestamps. [^0]: `$UDID` from: https://learn.microsoft.com/en-us/dotnet/maui/ios/cli?view=net-maui-10.0#launch-the-app-on-a-device [^1]: `$CODESIGN_KEY` from: https://learn.microsoft.com/en-us/dotnet/maui/ios/deployment/publish-cli?view=net-maui-10.0
1 parent 53030d9 commit e838af9

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

‎Chefs/App.xaml.cs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ protected override async void OnLaunched(LaunchActivatedEventArgs args)
4848
Host = await builder.NavigateAsync<ShellControl>();
4949
Shell = MainWindow.Content as ShellControl;
5050

51+
this.Log().LogWarning("Chefs App Finished Launching");
52+
5153
if (_exitAfterLaunching)
5254
{
5355
Exit();

‎Chefs/Chefs.csproj‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,20 @@
1515
<OutputType>Exe</OutputType>
1616
<UnoSingleProject>true</UnoSingleProject>
1717
<!-- Display name -->
18-
<ApplicationTitle>Chefs</ApplicationTitle>
18+
<ApplicationTitle>Chefs$(ApplicationTitleVendorSuffix)</ApplicationTitle>
1919

2020
<!-- App Identifier -->
21-
<ApplicationId>uno.platform.chefs.skia</ApplicationId>
21+
<ApplicationId>uno.platform.chefs.skia$(ApplicationIdVendorSuffix)</ApplicationId>
2222

2323
<ApplicationId Condition="'$(IsCanaryBranch)'=='true'">$(ApplicationId)-canary</ApplicationId>
2424

2525
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
2626
<ApplicationVersion>1</ApplicationVersion>
2727
<UseMocks Condition="'$(UseMocks)'==''">true</UseMocks>
28+
<IsAotCompatible>true</IsAotCompatible>
29+
<PublishAot Condition=" '$(SkiaPublishAot)' == 'true' And $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">true</PublishAot>
30+
<PublishAot Condition=" '$(SkiaPublishAot)' == 'true' And $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">true</PublishAot>
31+
<PublishAot Condition=" '$(PublishAot)' == '' And '$(SkiaPublishAot)' != '' ">$(SkiaPublishAot)</PublishAot>
2832
<!--
2933
If you encounter this error message:
3034

0 commit comments

Comments
 (0)