Xcode
has a view debugger tool that allows to inspect view hierarchy.
I am working on iOS Xamarin
app and would like to debug its view.
The app runs on a simulator launched from Visual Studio
.
Xcode's attach to process tool does not see PID of the running simulator.
How can I attach Xcode
view debugger to this process? Or perhaps there is another way of debugging view hierarchy of a Xamarin
app?
You can either launch the App and then attach the debugger or attach and then launch. Either way use the Xcode Debug menu to attach the debugger to a process: If the App is not yet running you will need to attach to it by name.
To debug a simple app in VS Code, press F5 and VS Code will try to debug your currently active file. However, for most debugging scenarios, creating a launch configuration file is beneficial because it allows you to configure and save debugging setup details.
Visual Studio for Mac has debuggers with support for.NET Core,.NET Framework, Unity, and Xamarin applications. Visual Studio for Mac uses the Mono Soft Debugger, which is implemented into the Mono runtime, allowing Visual Studio for Mac to debug managed code across all platforms.
Remote debugging. VS Code does not itself support remote debugging: this is a feature of the debug extension you are using, and you should consult the extension's page in the Marketplace for support and details. There is, however, one exception: the Node.js debugger included in VS Code supports remote debugging.
Since you do not have an Enterprise license and thus Xamarin Inspector which is integrated in the Visual Studio debug workflow, you can use Xcode but of course you have to manually apply changes back to your C#/F# code.
lldb
to access the app and Mono prevents that via a ptrace
call (there are ways around this via breaking on mono_assembly_init_with_opt
and doing an early return on it, but that is another story)Debug/Attach to process by PID or Name
menu optionIf you do not know the process name, obtain the process id of the Xamarin.iOS
application that is running on the simulator
ps
ps ax | grep -i Weather | cut -d " " -f 2
7864
In Xcode attach to that process
Wait a couple of seconds
Now you can select View UI Hierarchy
from the process info icon (far right icon from the Process name/id) via View process in other ways
Note: View the process name and you can use that in the future instead of the pid
, in this case it is WeatherApp.iOS
(see screen shot, top left corner)
Note: The above screenshot is using the demo Xamarin.Forms
WeatherApp (xamarin-forms-samples/Weather)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With