Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
488 views
in Technique[技术] by (71.8m points)

ios - How to attach Xcode view debugger to the simulator launched from Visual Studio?

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.

  1. Via VS4M start your app on the simulator in order to install it
  2. Stop debugging your app in VS4M
    • Xcode needs to use 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)
  3. Manually launch your app in the simulator
  4. Open Xcode
    1. You will need to create an iOS project
      • Anything project will do, it is so Xcode will enable the Debug/Attach to process by PID or Name menu option
  5. If you do not know the process name, obtain the process id of the Xamarin.iOS application that is running on the simulator

    • You can use ps

    ps ax | grep -i Weather | cut -d " " -f 2

    7864

  6. In Xcode attach to that process

    • Debug/Attach to process by PID or Name

enter image description here

  1. Wait a couple of seconds

    • or longer, sometimes Xcode can take a while and other times it is instant (?)
  2. 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

enter image description here

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)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...