Skip to content

Ahead-of-time compilation is not supported for the target runtime identifier 'ios-arm64' #21978

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

Closed
trampster opened this issue Jan 15, 2025 · 4 comments
Labels
need-attention An issue requires our attention/response
Milestone

Comments

@trampster
Copy link

Apple platform

iOS

Framework version

net9.0-*

Affected platform version

.net 9.0.101

Description

Turning on NativeAOT following the instructions here: https://learn.microsoft.com/en-us/dotnet/maui/deployment/nativeaot?view=net-maui-9.0
results in the following error.

/usr/local/share/dotnet/sdk/9.0.101/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(90,5): error NETSDK1203: Ahead-of-time compilation is not supported for the target runtime identifier 'ios-arm64'.

Steps to Reproduce

  1. Create a .net maui project targeting iOS
  2. Follow the instructions here to turn on Native AOT https://learn.microsoft.com/en-us/dotnet/maui/deployment/nativeaot?view=net-maui-9.0
  3. build using dotnet publish -f net9.0-ios -r ios-arm64
    -> error occurs

Did you find any workaround?

No

Build logs

No response

@rolfbjarne
Copy link
Member

Can you create a binlog by doing this:

dotnet publish -f net9.0-ios -r ios-arm64 -bl:msbuild.binlog

zip it up (can't attach *.binlog files here):

zip -9 msbuild.binlog.zip msbuild.binlog

and then attach the resulting binlog here?

@rolfbjarne rolfbjarne added the need-info Waiting for more information before the bug can be investigated label Jan 15, 2025
@rolfbjarne rolfbjarne added this to the Future milestone Jan 15, 2025
@trampster
Copy link
Author

msbuild.binlog.zip

@microsoft-github-policy-service microsoft-github-policy-service bot added need-attention An issue requires our attention/response and removed need-info Waiting for more information before the bug can be investigated labels Jan 15, 2025
@trampster
Copy link
Author

trampster commented Jan 15, 2025

I managed to get it to work by changing:

<PublishAot>true</PublishAot>

to: <PublishAot Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">true</PublishAot>

I had unconditionally set PublishAot to true for the purpose of testing NativeAOT.

It's supprising to me that this fixed it because in both cases it should be set to true. Something strange is going on here. Hopefully the binlog will help to figure it out.

@rolfbjarne
Copy link
Member

I can reproduce this with the following csproj:

<Project Sdk="Microsoft.NET.Sdk">
   <PropertyGroup>
      <TargetFrameworks>net9.0-ios;net9.0</TargetFrameworks>
      <OutputType>Exe</OutputType>
      <PublishAot>true</PublishAot>
   </PropertyGroup>
</Project>

It seems the net9.0 target framework interferes somehow. I think this is happening:

  • A package restore is automatically done.
  • Package restores happens for all target frameworks.
  • PublishAot=true is set for all target frameworks, so it's set when restoring net9.0
  • The runtime identifier is set on the command line, so it also takes effect when restoring net9.0
  • This combination is not allowed: TargetFramework=net9.0 + PublishAot=true + RuntimeIdentifier=ios-arm64, thus the error.

There are two workarounds:

  • Pass --no-restore to dotnet publish
  • Don't pass -r ios-arm64 to dotnet publish (it's the default anyways for TargetFramework=net9.0-ios).

This issue is already filed here, so I'm closing this as a duplicate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need-attention An issue requires our attention/response
Projects
None yet
Development

No branches or pull requests

2 participants