Home > Net >  visual studio mac: MAUI app archieve fails with three errors
visual studio mac: MAUI app archieve fails with three errors

Time:12-03

For days I am trying to archive my ios app, i set up provisioning and everything right, but when I run this command:

sudo dotnet publish -f:net6.0-ios -c:Release -r ios-arm64 --self-contained

I get three errors:

1)

 error NETSDK1032: The RuntimeIdentifier platform 'ios-arm64' and the PlatformTarget 'x64' must be compatible. [/Users/juliustolksdorf/Projects/Skillbased/app/skillbased_prod/Skillbased/Skillbased.csproj::TargetFramework=net6.0-ios]
  1. /project.assets.json' doesn't have a target for 'net6.0-ios'. Ensure that restore has run and that you have included 'net6.0-ios' in the TargetFrameworks for your project.

A bundle identifier is required. Either add an 'ApplicationId' property in the project file, or add a 'CFBundleIdentifier' entry in the project's Info.plist file.

Error 1 I can ommit by editing the csproj.user file

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <IsFirstTimeProjectOpen>False</IsFirstTimeProjectOpen>
    <ActiveDebugFramework>net6.0-ios</ActiveDebugFramework>
    <ActiveDebugProfile>iPhone 14 Pro Max iOS 16.1</ActiveDebugProfile>
    <SelectedPlatformGroup>Simulator</SelectedPlatformGroup>
    <DefaultDevice>iPhone 14 Pro Max iOS 16.1</DefaultDevice>
  </PropertyGroup>
  <PropertyGroup Condition="'$(TargetPlatformIdentifier)'=='iOS'">
    <RuntimeIdentifier>iossimulator-x64</RuntimeIdentifier>
    <PlatformTarget>x64</PlatformTarget>
  </PropertyGroup>
</Project>

and taking out x64. Then the error does no longer appear on archive, but I cannot build my app on emulator anymore when I do this. Great success.

Error number 2 I was neber able to omit, what is especially wired is that it is talking about a sub project (middleware.data) and not the main project. What am I supposed to do with that information?

And error number 3 is just stupid; ofc I have set a bundle ID in my csproj file

<!-- App Identifier -->
        <ApplicationId>com.skillbased.skillbasedapp</ApplicationId>
        <ApplicationIdGuid>2041a417-5399-434b-95f8-83e997177fb7</ApplicationIdGuid>

Why does it hate me so much?

I am running this on visual studio mac

I really need your help!

CodePudding user response:

Firstly, publishing is only supported through the .NET command line interface at this time. To publish your app, open a terminal and navigate to the folder for your .NET MAUI app project. Run the dotnet publish command like below to create an .ipa:

dotnet publish -f:net6.0-ios -c:Release /p:ArchiveOnBuild=true /p:_DotNetRootRemoteDirectory=/Users/{macOS username}/Library/Caches/Xamarin/XMA/SDKs/dotnet/

For more details, you can refer to enter image description here

If it looks any different, or says it isnt trusted, it will also fail. Do not click on the certificate and put it on "ALWAYS TRUST". It MUST use application defaults.

If it isnt autotrusted, REMOVE it and create a new one.

Then make sure you also have these certificates installed:

enter image description here

If you dont have them, download them here:

https://www.apple.com/certificateauthority/

Download all of them that expire after one year from now. (the World wide ones) Shouldnt be more than 4.

Double click them, they should show up in your keychain.

If your certificate was invalid before, it will now show as valid.

Now try building your app with the profile installed and with a release config. This will now finally prompt you for the password to your keychain.

If this is put in correctly you can finally build your app with:

dotnet publish -f:net6.0-ios -c:Release -r ios-arm64 --self-contained

Do NOT use a SUDO.

And thats it. Easy right?

  • Related