Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Tracked by #1
lemonmojo opened this issue Apr 20, 2023 · 8 comments
Open
Tracked by #1
Labels
enhancement New feature or request

Comments

@lemonmojo
Copy link
Member

lemonmojo commented Apr 20, 2023

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

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

Regarding iOS:
dotnet/runtime#80905

Regarding Android:
dotnet/runtime#76983

@lemonmojo lemonmojo added the enhancement New feature or request label Apr 20, 2023
@lemonmojo lemonmojo changed the title Try to compile for iOS Try to compile for other platforms Apr 22, 2023
@lemonmojo lemonmojo reopened this Jul 10, 2023
@lemonmojo
Copy link
Member Author

Check again in .NET 8 Preview 6

@lemonmojo
Copy link
Member Author

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
Copy link
Member Author

lemonmojo commented Jul 12, 2023

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
Copy link
Member Author

lemonmojo commented Jul 12, 2023

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 lemonmojo changed the title Try to compile for other platforms Try to compile for other platforms (iOS, Android) Jul 12, 2023
@MichalStrehovsky
Copy link

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

@lemonmojo
Copy link
Member Author

@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
Copy link
Member Author

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

@lemonmojo lemonmojo changed the title Try to compile for other platforms (iOS, Android) Try to compile for other platforms (Android, tvOS, visionOS) Nov 21, 2023
@lemonmojo
Copy link
Member Author

There's hope for visionOS support: dotnet/runtime#87929

@lemonmojo lemonmojo mentioned this issue Nov 22, 2023
57 tasks
@lemonmojo lemonmojo changed the title Try to compile for other platforms (Android, tvOS, visionOS) Try to compile for other platforms (tvOS, watchOS, visionOS, Android) Nov 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants