mauivisual-studio-mac-2022

Compiling/Archiving MAUI project in Release configuration fails


I have a couple MAUI projects that include references to other projects which provide access to an API. The referenced projects generate dll's. When I compile the MAUI app in release mode and target my physical iPhone, the compile fails stating "Asset file '../project.Domain.Shared/obj/project.assets.json' doesn't have a target for 'net6.0-ios'. The referenced project is the .dll generating project that shouldn't (and cannot) contain a net6.0-ios property. This error only occurs if I attach my phone and target it during the compile. I can attach an Android device and compile in release mode without errors and even create an archive. Any help in resolving this issue is appreciated.

I tried adding the net6.0-ios property in the project that was referenced in the error, but doing so caused the whole solution to fail to compile. I am using Xcode 14.x and have seen other posts that suggested using version 13.x may resolve the problem. I tried that and still was unable to get the project to compile correctly.


Solution

  • For iOS, MAUI currently only supports publishing on the .NET command line. You need to use the command dotnet publish -f:net6.0-ios -c:Release... to create the .ipa file. For more details, please refer to this official document: Publish a .NET MAUI app for iOS - .NET MAUI