beyondnet icon indicating copy to clipboard operation
beyondnet copied to clipboard

Try to compile for other platforms (tvOS, watchOS, visionOS, Android)

Open lemonmojo opened this issue 2 years ago • 8 comments

Outdated Info (both iOS and Android are supported now):

As of May 2023, NativeAOT is only (officially) supported on desktop platforms.

Regarding iOS: https://github.com/dotnet/runtime/issues/80905

Regarding Android: https://github.com/dotnet/runtime/issues/76983

lemonmojo avatar Apr 20 '23 16:04 lemonmojo

Check again in .NET 8 Preview 6

lemonmojo avatar Jul 10 '23 17:07 lemonmojo

As expected, this is a supported scenario in Preview 6: https://devblogs.microsoft.com/dotnet/announcing-dotnet-8-preview-6/ So we can test this now.

lemonmojo avatar Jul 12 '23 09:07 lemonmojo

Unfortunately it looks like NativeAOT support for iOS in .NET 8 Preview 6 is currently limited to app projects and classlibs are not supported.

@filipnavara is that correct?

The current state of the iOS experiments is here.

lemonmojo avatar Jul 12 '23 10:07 lemonmojo

Building for ios-arm64 works now with some workarounds in the csproj:

  • PublishAotUsingRuntimePack needs to be set to true (This is actually documented)
  • _IsAppleMobileLibraryMode needs to be set to false
  • The linker must be configured to target iOS by adding this:
<ItemGroup>
    <LinkerArg Include="-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk" />
    <LinkerArg Include="-mios-version-min=16.0" />
</ItemGroup>

A "dummy" (unused) Main method must be present in the .NET project that's to be compiled with NativeAOT.

Many thx for your support @filipnavara!

lemonmojo avatar Jul 12 '23 13:07 lemonmojo

Btw, for the Android part, that should also work if you use the Bionic RID. This issue has the latest details: https://github.com/dotnet/runtime/issues/87340. The official doc is not written up yet.

MichalStrehovsky avatar Jul 13 '23 03:07 MichalStrehovsky

@MichalStrehovsky Many thx for the info! I'll get to Android part once I'm happy with the way things work for Apple targets.

lemonmojo avatar Jul 13 '23 07:07 lemonmojo

https://github.com/dotnet/runtime/pull/93658 will add proper iOS library support to .NET. Once that lands, we should remove the various workarounds that are in place today.

lemonmojo avatar Nov 14 '23 08:11 lemonmojo

There's hope for visionOS support: https://github.com/dotnet/runtime/issues/87929

lemonmojo avatar Nov 21 '23 11:11 lemonmojo