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

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

问题描述

Xcode 有一个视图调试器工具,允许检查视图层次结构.

Xcode has a view debugger tool that allows to inspect view hierarchy.

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

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 的附加到进程工具没有看到正在运行的模拟器的 PID.

Xcode's attach to process tool does not see PID of the running simulator.

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

How can I attach Xcode view debugger to this process? Or perhaps there is another way of debugging view hierarchy of a Xamarin app?

推荐答案

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

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. 通过 VS4M 在模拟器上启动您的应用以进行安装
  2. 停止在 VS4M 中调试您的应用
    • Xcode 需要使用 lldb 来访问应用程序,Mono 通过一个 ptrace 调用来防止这种情况发生(有一些方法可以通过破坏 mono_assembly_init_with_opt> 并尽早返回,但那是另一回事)
  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)
  1. 您需要创建一个 iOS 项目
    • 任何项目都可以,因此 Xcode 将启用 Debug/Attach to process by PID or Name 菜单选项

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

  • If you do not know the process name, obtain the process id of the Xamarin.iOS application that is running on the simulator

    • 你可以使用ps

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

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

    7864

  • 在 Xcode 中附加到该进程

  • In Xcode attach to that process

    • 通过 PID 或名称调试/附加到进程

    1. 稍等片刻

    1. Wait a couple of seconds

    • 或者更长时间,有时 Xcode 可能需要一段时间,有时它是即时的 (?)

    现在您可以通过以其他方式查看流程从流程信息图标(流程名称/id的最右侧图标)中选择View UI Hierarchy/p>

  • 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

    注意:查看进程名称,以后可以用它代替pid,在本例中是WeatherApp.iOS(见屏幕截图,左上角)

    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)

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

    Note: The above screenshot is using the demo Xamarin.Forms WeatherApp (xamarin-forms-samples/Weather)

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

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