如何将Xcode视图调试器附加到从Visual Studio启动的模拟器上? [英] How to attach Xcode view debugger to the simulator launched from Visual Studio?

查看:96
本文介绍了如何将Xcode视图调试器附加到从Visual Studio启动的模拟器上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Xcode具有视图调试器工具,该工具可以检查视图层次结构.

我正在使用iOS Xamarin应用,并且想调试其视图. 该应用程序在从Visual Studio启动的模拟器上运行.

Xcode附加到处理工具后,看不到正在运行的模拟器的 PID .

如何将Xcode视图调试器附加到此过程?也许还有另一种调试Xamarin应用程序的视图层次结构的方法?

解决方案

由于您没有Enterprise许可证,因此没有Xamarin Inspector(集成在Visual Studio调试工作流程中),因此可以使用Xcode,但是当然必须手动将更改应用回您的C#/F#代码.

  1. 通过VS4M在模拟器上启动您的应用以进行安装
  2. 停止在VS4M中调试您的应用
    • Xcode需要使用lldb来访问应用程序,而Mono通过ptrace调用阻止了此操作(有很多方法可以通过中断mono_assembly_init_with_opt并对其进行早期返回,但这是另一回事了)
  3. 在模拟器中手动启动您的应用
  4. 打开Xcode

    1. 您将需要创建一个iOS项目
      • 任何项目都可以,Xcode会启用Debug/Attach to process by PID or Name菜单选项

  5. 如果您不知道进程名称,请获取在模拟器上运行的Xamarin.iOS应用程序的进程ID

    • 您可以使用ps

    ps斧| grep -i天气|切-d" -f 2

    7864

  6. 在Xcode中附加到该进程

    • 调试/附加以按PID或名称进行处理

  1. 等待几秒钟

    • 或更长时间,有时Xcode可能需要一段时间,而其他时候它是即时的(?)
  2. 现在,您可以通过View process in other ways

  3. 从过程信息图标(过程名称/id中最右边的图标)中选择View UI Hierarchy

注意:查看进程名称,以后可以使用它代替pid,在这种情况下为WeatherApp.iOS(请参见左上角的屏幕截图)

注意:上面的屏幕截图使用的是演示Xamarin.Forms WeatherApp(xamarin-forms-samples/Weather)

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?

解决方案

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

  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

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)

这篇关于如何将Xcode视图调试器附加到从Visual Studio启动的模拟器上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆