如何将 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.
- 通过 VS4M 在模拟器上启动您的应用以进行安装
- 停止在 VS4M 中调试您的应用
- Xcode 需要使用
lldb
来访问应用程序,Mono 通过一个ptrace
调用来防止这种情况发生(有一些方法可以通过破坏mono_assembly_init_with_opt
> 并尽早返回,但那是另一回事)
- Xcode 需要使用
- Via VS4M start your app on the simulator in order to install it
- Stop debugging your app in VS4M
- Xcode needs to use
lldb
to access the app and Mono prevents that via aptrace
call (there are ways around this via breaking onmono_assembly_init_with_opt
and doing an early return on it, but that is another story)
- Xcode needs to use
- 您需要创建一个 iOS 项目
- 任何项目都可以,因此 Xcode 将启用
Debug/Attach to process by PID or Name
菜单选项
- 任何项目都可以,因此 Xcode 将启用
如果您不知道进程名称,请获取在模拟器上运行的 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 或名称调试/附加到进程
稍等片刻
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)