uno: vs4mac: won't deploy / run / debug UNO applications for iOS, MacCatalyst, or MacOS

Current behavior

Uno iOS, MacCatalyst, or MacOS applications will not deploy, run, or debug from Visual Studio 2022 for Mac.

NOTES

  • iOS apps will deploy, run and debug when launched from Visual Studio 2022 Windows that is paired to a Mac that won’t when running vs4mac.
  • The following types of applications will deploy, run and debug from vs4mac:
    • Xamarin: iOS, Mac
    • Xamarin.Forms: iOS
    • NET6.0: iOS, MacCatalyst, MacOS
    • MAUI iOS, MacCatalyst, MacOS
  • Have tried on two different Macs - one of which had a fresh install of xCode and vs4mac
  • Have run uno-check on both Macs
  • Not sure if this correlates to most recent xCode update or most recent vs4mac update

Expected behavior

Well, eh, it works.

How to reproduce it (as minimally and precisely as possible)

On Mac:

  1. in terminal, execute the following: ‘dotnet new unoapp -o UnoApp’
  2. In vs4mac, open the solution created in the previous step
  3. Set the debug target to any one of the following:
    • MacCatalyst
    • MacOS
    • iOS Simulator
    • iOS device
  4. Build (should be successful)
  5. start a debug run
  6. see ‘Execution Failed’ message at the bottom left of Visual Studio window
  7. notice that there are no logs in Deploy window

Workaround

Please, please, please share one if you have one! See thread, below, for work around!

Works on UWP/WinUI

No response

Environment

Uno.WinUI / Uno.WinUI.WebAssembly / Uno.WinUI.Skia

NuGet package version(s)

All Platforms:

    <PackageReference Include="Uno.WinUI" Version="4.6.19" />
    <PackageReference Include="Uno.WinUI.RemoteControl" Version="4.6.19" Condition="'$(Configuration)'=='Debug'" />
    <PackageReference Include="Uno.UI.Adapter.Microsoft.Extensions.Logging" Version="4.6.19" />
    <PackageReference Include="Microsoft.Extensions.Logging.Console" Version="5.0.0" />
    <PackageReference Include="Uno.WinUI.Lottie" Version="4.6.19" />

iOS and MacCatalyst:

        <PackageReference Include="Uno.Extensions.Logging.OSLog" Version="1.4.0" />

Affected platforms

iOS, macOS (AppKit), Mac Catalyst

IDE

Visual Studio for Mac

IDE version

VisualStudio 2022 for Mac, version 17.4 (2406)

Relevant plugins

No response

Anything else we need to know?

No response

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 27 (27 by maintainers)

Most upvoted comments

Sorry to hear Microsoft is giving up on VS4Mac. Thanks for keeping this in the backlog all this time.

@spouliot : sadly, iossimulator-x64 performance on an M2 MBP is still better than the android-arm64 performance on the same M2 MBP!

AN UPDATE

The past month or so, I’ve been working around this issue using the following workflow:

WORK AROUND : BUILD + DEBUGGING

In [my_project].Mobile.csproj, replace the following:


  <PropertyGroup>
		<TargetFrameworks>net7.0-android</TargetFrameworks>
		<TargetFrameworks>$(TargetFrameworks);net7.0-ios</TargetFrameworks>
		<TargetFrameworks>$(TargetFrameworks);net7.0-maccatalyst</TargetFrameworks>


  	</PropertyGroup>

… with the following:

  <PropertyGroup>
    <!--
		<TargetFrameworks>net7.0-maccatalyst</TargetFrameworks>
		<TargetFrameworks>net7.0-macos</TargetFrameworks>
		<TargetFrameworks>net7.0-maccatalyst</TargetFrameworks>
		<TargetFrameworks>net7.0-android</TargetFrameworks>
    -->
		<TargetFrameworks>net7.0-ios</TargetFrameworks>
  </PropertyGroup>

… where you will manually change which line to uncomment, depending on the target platform of your choice.

iOS

You may have to change to the following, depending if your debug target is an iOS simulator or a device:

SIMULATOR
    <RuntimeIdentifier Condition="'$(TargetFramework)' == 'net7.0-ios'">iossimulator-x64</RuntimeIdentifier>

Strange enough, iossimulator-x64 works on a M-Series Mac!?!?

DEVICE
    <RuntimeIdentifier Condition="'$(TargetFramework)' == 'net7.0-ios'">ios-arm64</RuntimeIdentifier>

Also note, for iOS device debugs, I have to do a Rebuild All after any code change. If not, the linker gets all mucked up and I get a crash at launch from missing package references.

ANDROID

You may have to change to the following, depending if your debug target is an Android simulator (running on a x64 or M-Series Mac) or a device:

x64 SIMULATOR
        <RuntimeIdentifier>android-x64</RuntimeIdentifier>
DEVICE or M-Series Simulator
        <RuntimeIdentifier>android-arm64</RuntimeIdentifier>

MacOS

MacCatalyst builds typically work as well as iOS builds do, but MacOS builds either won’t build or won’t deploy (so no debugging). When that happens, the following process seems to work:

  • make the following change to your .Mobile.csproj file
  <PropertyGroup>
    <!--
		<TargetFrameworks>net7.0-maccatalyst</TargetFrameworks>
		<TargetFrameworks>net7.0-macos</TargetFrameworks>
		<TargetFrameworks>net7.0-maccatalyst</TargetFrameworks>
		<TargetFrameworks>net7.0-android</TargetFrameworks>
    -->
		<TargetFrameworks>net7.0-macos</TargetFrameworks>
  </PropertyGroup>
  • if your Mac has Apple silicon, make the following change to your .Mobile.csproj file
    <RuntimeIdentifier Condition="'$(TargetFramework)' == 'net7.0-macos'">osx-arm64</RuntimeIdentifier>
  • in VSMAC, set the .Mobile project as the Startup Project
  • likewise, depending on if your Mac has Apple or Intel silicon, set the build configuration to Debug | Arm64 or Debug | x64
  • close VSMAC
  • delete any globals.json that are in the project’s folder hierarchy
  • delete any .vs folders in the project’s folder hierarchy
  • delete any .vsconfig files in the project’s folder hierarchy
  • delete all build files by doing the following from the solution’s root folder:
% rm -rf **/bin
% rm -rf **/obj

Note: you might have to do this more than once if you have VSCode open. For good measure, repeat the above until you see zsh: no matches found: **/obj and zsh: no matches found: **/bin.

  • reopen VSMAC and wait for the NuGet Package Restore to complete
  • your MacOS

WORK AROUND : ARCHIVE

Archive the iOS app from the command line by doing the following:

% dotnet restore /p:RuntimeIdentifier=ios-arm64
% dotnet publish -f net7.0-ios -r ios-arm64 -c Release --no-restore --self-contained

@spouliot : Thanks for the validation. Worth a million points of karma for the Uno team!

@baskren thanks for your detailed investigation. This is indeed issue https://github.com/dotnet/sdk/issues/21877 [1] and your workaround is correct, if sadly not ideal for day-to-day development.

IOW building for a single platform avoids the possible mixup between -f and -r arguments which manifest themselves in different ways.

AFAIK VSWin has it’s own dotnet restore-like code which explains why this is not a problem when building projects from Windows.

[1] https://github.com/xamarin/xamarin-macios/issues/16401 closed as a dupe of https://github.com/dotnet/sdk/issues/21877 only manifested itself when net6.0-macos was present, which MAUI does not support. It might be (part of) why this error is less common on MAUI, but there are other random factors too.