What's the modern way of debugging .NET 8 iOS apps on Mac (including their extensions)?

180 Views Asked by At

There are two related questions in this one:

1. What's the modern way expected to debug .NET 8+ apps on Mac?

The question occurs because of: VS for Mac is being retired (May, 2024) and even now it does not officially support .NET 8 (it's not an option for the future anyways), VSC (Mac) doesn't seem have any official debuggers from MS to debug iOS apps. There is CodeLLDB extension for VSC, but it also doesn't seem like supports iOS debugging. (Native .NET debugger there doesn't seem support that as well). Microsoft position in regards to that is not clear at all to me.

2. What's the way to debug .NET iOS Extension on Mac or Windows at all?

I can't manage not only to debug iOS Extension from anywhere (nor even VS for Windows), but can't even deploy it from VS for Windows.

My solution includes two projects. (All .NET 8 with ios workload (the host app can be with maui workload, but the final result is the same)):

<Project Sdk="Microsoft.NET.Sdk">
 <PropertyGroup>
 <TargetFramework>net8.0-ios</TargetFramework> 

First project is the iOS host app. Second project is the iOS Extension project like this:

<IsAppExtension>True</IsAppExtension>
<IsWatchExtension>False</IsWatchExtension>
<PlatformTarget>ARM64</PlatformTarget> 
<MtouchDevice>iPhone</MtouchDevice> 

It's referenced in the the host app like this:

<ProjectReference Include="..\ext\ext.csproj">
 <IsAppExtension>true</IsAppExtension>
 <IsWatchApp>false</IsWatchApp>
</ProjectReference> 

The issue is I can't make the project deployed and run debugging. After long tries and experiments I finally managed to build it with no errors (because the extension project required explicitly setting up its PlatformTarged independently on the host app project (when building with VS MSBuild on Windows)) (and it gets built and deployed well with dotnet build executed on Mac). But now, I still get these errors:

Please select a valid device before running the application (related to the extension project) Xamarin.iOS does not support deploying the previous version. Please ensure your solution builds before deploying it. (related to the host project, although everything's fine when the project is built alone without the Extension referenced)

4>Deploy failed ========== Build: 2 succeeded, 0 failed, 2 up-to-date, 0 skipped ==========
========== Build completed at 10:50 PM and took 01:32.718 minutes ==========
========== Deploy: 0 succeeded, 2 failed, 0 skipped ==========
========== Deploy completed at 10:50 PM and took 01:32.719 minutes ==========

When I set <MtouchDevice>iPhone</MtouchDevice> for the extension, it started mentioning Signing error. When I set that explicitly for the extension project it still gives me such error. Also, as long as those the-new-.net-style project files with workloads used, I can't select any CPU/Platform explicitly in the Configuration Manager, as having the only option "Any CPU" for the target project(s). So, I can't make the projects run debugging (neither extension's nor even the host app)!


Another option to build and debug the code is VS for Mac (even though it's currently retiring), but I can't see any way to Debug the Extension project anyways, as there is even no option to select a device to deploy/run it when selecting the Target project as Extension project (similar to how it work on Xcode swift) > the UI doesn't allow to select the Target device:

enter image description here

1

There are 1 best solutions below

0
SamChen On

We recently upgraded our Xamarin iOS app to .net8 iOS.

The only way to debug on Mac is using Rider from JetBrains. Other than rider, you will need a windows machine to pair with a Mac to debug using visual studio on the windows machine.