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

Suddenly, iOS crashes with “Model building is not supported when publishing with NativeAOT. Use a compiled model” #23653

Closed
DonkeyKongJr opened this issue Jul 17, 2024 · 8 comments
Labels
area-publishing Issues with the app packaging/publishing process (ipk/apk/msix/trimming) platform/iOS 🍎 potential-regression This issue described a possible regression on a currently supported version., verification pending s/needs-attention Issue has more information and needs another look s/triaged Issue has been reviewed t/bug Something isn't working

Comments

@DonkeyKongJr
Copy link

Description

We have been working on an Android and iOS app for the last year or so and suddenly (somewhere around the 9th of July) our iOS began to break right on the EF Core initialization with the error "Model building is not supported when publishing with NativeAOT. Use a compiled model".

However, if we travel back in time and install a release via AppCenter prior that date everything works fine, but if the pull some code before that date and build it now, publish via AppCenter and install it on device the app crashes right away.

The iOS publish section for Releases are the following:

  <PropertyGroup Condition="$(TargetFramework.Contains('-ios')) and '$(Configuration)' == 'Release'">
    <CodesignKey>Some Key</CodesignKey>
    <CodesignProvision>Some Provisioing</CodesignProvision>
    <ArchiveOnBuild>True</ArchiveOnBuild>
    <UseInterpreter>True</UseInterpreter>
    <CodesignEntitlements>Platforms\iOS\Entitlements.plist</CodesignEntitlements>
    <MtouchProfiling>True</MtouchProfiling>
  </PropertyGroup>

We were on Ef-Core 8.0.2 but neither bumping it to 8.0.7 or downgrading (as some other suggested) to 8.0.1 helped in this case. I have read somewhere, that compiled models are not even supported on .NET 8, which adds up to the confusion.

We are building with Xcode 15.2 on Azure Pipelines. The Debug build works without any problems.

Android is still working fine and has no problems at all.

Steps to Reproduce

No response

Link to public reproduction project repository

No response

Version with bug

8.0.70 SR7

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

8.0.20 SR4

Affected platforms

iOS

Affected platform versions

iOS 17.5.1

Did you find any workaround?

No.

Relevant log output

No response

@DonkeyKongJr DonkeyKongJr added the t/bug Something isn't working label Jul 17, 2024
Copy link
Contributor

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

@samhouts samhouts added platform/iOS 🍎 potential-regression This issue described a possible regression on a currently supported version., verification pending labels Jul 17, 2024
@samhouts
Copy link
Member

Have you tried the workaround mentioned in #23577 (comment)? If it works for you, we can perhaps close this as a duplicate. Thanks!

@samhouts samhouts added the s/needs-info Issue needs more info from the author label Jul 17, 2024
@DonkeyKongJr
Copy link
Author

@samhouts yes, adding

<MtouchInterpreter>all</MtouchInterpreter>

solved the problem for now. thank you.

@dotnet-policy-service dotnet-policy-service bot added s/needs-attention Issue has more information and needs another look and removed s/needs-info Issue needs more info from the author labels Jul 18, 2024
@Zhanglirong-Winnie Zhanglirong-Winnie added the s/triaged Issue has been reviewed label Jul 18, 2024
@samhouts
Copy link
Member

Duplicate of #23577

@samhouts samhouts marked this as a duplicate of #23577 Jul 18, 2024
@Axemasta
Copy link
Contributor

I am still seeing this issue with EFCore 8 and the following in my maui csproj:

<PropertyGroup Condition="$(TargetFramework.Contains('-ios')) and '$(Configuration)' == 'Release'">
	<ArchiveOnBuild>true</ArchiveOnBuild>
	<MtouchInterpreter>all</MtouchInterpreter>
	<PublishAot>false</PublishAot>
</PropertyGroup>

When building for release (only) i get the following exception at runtime:

2024-07-18 17:13:54.718136+0100 MyApp[13004:8774208] [2024-07-18 17:13:54.690 +01:00] [ERR] [DatabaseInitializer] An exception occurred initializing the database
System.InvalidOperationException: Model building is not supported when publishing with NativeAOT. Use a compiled model.

@DonkeyKongJr
Copy link
Author

@Axemasta try adding <UseInterpreter>True</UseInterpreter> as well.

@Axemasta
Copy link
Contributor

@Axemasta try adding <UseInterpreter>True</UseInterpreter> as well.

That did the trick! added bonus my dotnet publish times on the build agent went from an average of 30 minutes / 100MB ipa to 3 minutes / 50MB ipa!

@DonkeyKongJr
Copy link
Author

Great to hear!

@github-actions github-actions bot locked and limited conversation to collaborators Aug 19, 2024
@samhouts samhouts added the area-publishing Issues with the app packaging/publishing process (ipk/apk/msix/trimming) label Aug 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-publishing Issues with the app packaging/publishing process (ipk/apk/msix/trimming) platform/iOS 🍎 potential-regression This issue described a possible regression on a currently supported version., verification pending s/needs-attention Issue has more information and needs another look s/triaged Issue has been reviewed t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants