Repository navigation
Enable support for NativeAOT targeting iOS via opt-in feature #80905
Description
Overview
Supporting NativeAOT on iOS platforms as an experimental feature in .NET8 would enable our customers to try the NativeAOT toolchain and runtime with their iOS applications, in order to benefit from advantages mostly concentrated around application size savings and start-up performance.
In .NET8 the default toolchain and runtime when targeting iOS platforms will remain to be Mono, while NativeAOT would become available as an option.
This issues tracks progress on the identified work required for enabling NativeAOT on iOS platforms. The work is organised and tracked with GitHub issues divided by upcoming .NET8 preview releases in which they should become available. Some of the listed items can be considered as user stories and will require further break-down of work, while the others are plain tasks.
NOTE: The breakdown of GitHub issues does not impose hard deadlines. If some of the functionality does not get upstreamed for a particular preview version, this issue will be updated accordingly.
Tasks
.NET8 Preview 5
- NativeAOT: Export native methods from referenced assemblies. #65755
- Support marshalled delegates with NativeAOT on iOS platforms #82090
- Support targeting iOS platforms with ILCompiler #80908
- Enable AppleAppBuilder to bundle applications compiled with NativeAOT #80910
- Introduce symbol stripping build task for HelloiOS sample app #80977
- Expose managed Main with NativeAOT when compiling the application as a static library #81097
- [NativeAOT] Low level API support for Objective-C scenarios #77472
- Static registrar with NativeAOT design – discussion #80912
- Add a managed static registrar. Fixes #17324. macios#18268
.NET8 Preview 6
- HelloiOS sample for NativeAOT #80911
- Enable dotnet SDK to support targeting iOS with NativeAOT sdk#30068
- Add support for using NativeAOT. macios#17374
- Enable building NativeAOT for Apple mobile platforms #81024
- Adapt monotouch-test to work with NativeAOT macios#17774
- [nativeaot][tests] Add Native AOT iOS perf scenarios #85317
- [NativeAOT] Don't link Swift/CryptoKit on iOS-like platforms #87216
- Satellite assembly support in NativeAOT #86651
- Avoid linking to non-existent System.Net.Security.Native on tvOS #87605
- Support relative path for ICU_DAT_FILE_PATH on iOS/tvOS/Catalyst #87813
- NativeAOT supports targeting all iOS-like platforms:
ios,iossimulator,maccatalyst,tvosandtvossimulator - App size-regression and startup tracking for NativeAOT HelloiOS sample
.NET8 Preview 7
- NativeAOT: Do not pass
-dead_stripto the native linker macios#18552 - Enable NativeAOT cross-platform build for iOS-like platforms #87764
- NativeAOT: stop shipping assemblies macios#18472
- NativeAOT: Disable AggressiveAttributeTrimming with ILLink macios#18545
- Respect IsDynamicCodeSupported in more places in Linq.Expressions #88539
.NET8 GA
- Fix how
System.Linq.Expressions.dllis supported on iOS-like platforms #87924 - Support NativeAOT as a runtime variant for iOS platforms macios#17339
- Investigate limitations and document findings of enabling NativeAOT for MAUI iOS application #80907
- Enable dotnet/runtime runtime and functional tests for iOS platforms to run with NativeAOT #85294
- Trimming and extensions compatibility design – discussion #86649
- [NativeAOT] Add appropriate telemetry flags to track use of NativeAOT on iOS-like platforms #88844
- NativeAOT: Trimming and extensions compatibility - implementation macios#18584
- App size-regression and startup tracking for NativeAOT MAUI iOS
- NativeAOT: fix warnings in our code macios#18629
- NativeAOT: Document support for NativeAOT runtime with Xamarin macios#18585
.NET9
- NativeAOT library mode on iOS-like platforms #88737
- .NET: Use UnmanagedCallersOnlyAttribute instead of (or in addition to) MonoPInvokeCallbackAttribute macios#10470
- Overeager check for RuntimeIdentifier when PublishAot=true sdk#33414
- [NativeAOT] Properly implement targeting iOS-like platforms rather than pretending to be macOS #87610
- NativeAOT: re-enable dead stripping macios#18605
- .NET 9: Make .NET MAUI trimmer-friendly maui#18658
- [NativeAOT] App Store Connect warning ITMS-90999: Invalid executable #94655
- [ios][docs] Document how iOS library mode is supported #96742
- Document support for released app diagnostics with NativeAOT on iOS #106799
.NET10
.NET11
- Improve methodology for start-up profiling and measuring SOD for iOS platforms
- [perf] Add support for build time tracking in iOS scenarios performance#3162
- [NativeAOT] Extend the runtime pack approach to all supported platforms #87060
- Enable building/running libraries tests on iOS simulator and device with NativeAOT #81075
- [NativeAOT] Simplify build integration with external bundlers for Apple platforms #87187
- NativeAOT: Investigate whether we can narrow down the list of assemblies to look for UnmanagedCallersOnly entry points macios#18484
Other relevant issues:
- [NativeAOT] support calling UnmanagedCallersOnly functions before managed main() #77957
- [NativeAOT] Update documentation when building native libraries with a custom native host #82156
/cc: @marek-safar @SamMonoRT @steveisok @lambdageek @rolfbjarne @kotlarmilos @akoeplinger
Activity
SamMonoRT commentedon Jan 20, 2023
/cc @agocke @jkotas @AaronRobinsonMSFT
AaronRobinsonMSFT commentedon Jan 20, 2023
We should also have a note/item around diagnostics and document what the user experience will be on iOS. I believe it would be rather different and having a comprehensive list would help users make informed decisions about using NativeAOT and what to expect post deployment.
/cc @tommcdon
tommcdon commentedon Jan 20, 2023
Adding @thaystg @lateralusX. It is my understanding that Mono uses an in-proc debugger model due to mobile diagnostics restrictions.
filipnavara commentedon Jan 20, 2023
FWIW debugging with lldb on-device is possible, so in that sense it's comparable to the current model of debugging NativeAOT on Linux/macOS.
ivanpovazan commentedon Jan 23, 2023
@AaronRobinsonMSFT thank you for the suggestion. I have added it to the list.
[-]NativeAOT on iOS as an experimental feature in .NET8 [/-][+]Enable support for NativeAOT targeting iOS via opt-in feature[/+][NativeAOT] Add ability to generate library and exe entry points (#81873
curia-damiano commentedon May 19, 2023
Does this feature mean that it will be possible to export a .NET class library as a native iOS library?
8 remaining items
vitek-karas commentedon Aug 22, 2024
Moving to 10 since all the remaining 9 tasks are documentation and are tracked by separate issues.
AlexeiNaabal commentedon Sep 4, 2024
Could you please provide more information @ivanpovazan? We are now testing publish managed class to native library, only find out we have to enable self-contained. Maybe the after-procedural (like library builder) is ready, but the publish itself is not? when we set
<NativeLib>Shared</NativeLib>, the compiler force us to enable self-contained.Background: We already setup an embed mono runtime, thus self-contained is not suitable for our need :) Recently we are experimenting if we can extract certain managed class as native library for the native host to invoke, to see if it can improve performance.
pavelsavara commentedon Sep 4, 2024
This touches on our rooting/trimming WASM use-case #101434
curia-damiano commentedon Sep 4, 2024
As I see that this issue is not closed yet, I would like to ask this:
Do you think that this is possible with .NET 8? And if not, will it be possible in .NET 9?
lemonmojo commentedon Sep 4, 2024
@curia-damiano Sounds like the perfect use case for Beyond.NET. That being said, I would obviously very much appreciate if that was built in to .NET.
curia-damiano commentedon Sep 4, 2024
I was not aware of it, thank you very much @lemonmojo for telling me!
ivanpovazan commentedon Sep 4, 2024
@AlexeiNaabal
This is by design. Building a managed library into a shared native one embeds the runtime with it.
If I understand your setup correctly, you would have mono and NativeAOT runtime running in the same process, which is not a setup that is supported.
@curia-damiano
/cc: @kotlarmilos ^