Search code examples
iospublishmaui

.NET Maui Build Error Could not find Microsoft.iOS


I am on a PC Visual Studio CE 2022 attempting to archive and deploy for iOS. I am using the following command:

dotnet publish PopUpShop.Mobile.Maui -f net7.0-ios -c Release /p:ServerAddress=192.168.1.XXX /p:ServerUser='username' /p:TcpPort=58181 /p:ArchiveOnBuild=true

The process builds and connects to my Macbook but then throws this error:

C:\Program Files\dotnet\packs\Microsoft.iOS.Sdk\16.1.1477\tools\msbuild\iOS\Xamarin.Shared.targets(1738,3): error : Could not find Microsoft.iOS in /usr/local/share/dotnet/packs/Microsoft.iOS.Sdk/16.1.1477/

I am not quite sure where it is looking for /usr/local/share.... I assume that is on the Macbook.

Do I have to install that version of the SDK on the Macbook? If so how do I do that? (Not a mac user). I tried in Terminal

dotnet add package Microsoft.iOS.Sdk --version 16.1.1477

but it wants to add that to a specific project.


Solution

  • The problem was I was missing the /p:_DotNetRootRemoteDirectory='/Users/{mac_os_username}/Library/Caches/Xamarin/XMA/SDKs/dotnet/' parameter. For some reason it was not part of the cli string I copied. The error message doesn't help either, sends you down a rabbit hole.