启动后如何将调试器附加到 iOS 应用程序?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9721830/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 17:19:49  来源:igfitidea点击:

How to attach debugger to iOS app after launch?

iosxcodedebugging

提问by Locksleyu

I have an issue I am troubleshooting which occurs very infrequently and doesn't seem to happen when I have things running under Xcode.

我有一个问题,我正在排除故障,该问题很少发生,当我在 Xcode 下运行时似乎不会发生。

Is it possible to run an app normally (i.e. from Springboard) until my issue occurs, and then attach a debugger at that point?

是否可以正常运行应用程序(即从 Springboard),直到出现我的问题,然后在那时附加调试器?

I would prefer to do this without jailbreaking if possible.

如果可能的话,我更愿意在不越狱的情况下做到这一点。

回答by Ole Begemann

  • Attach your device connected your Mac
  • Debug > Attach to Process by PID or Name
  • In the dialog sheet, enter the name of your app as it appears in the Debug navigator when started via Xcode.
  • 将您的设备连接到 Mac
  • 调试 > 按 PID 或名称附加到进程
  • 在对话框表中,输入通过 Xcode 启动时出现在调试导航器中的应用程序名称。

If the app is already running, the debugger will attach to the running process. If it isn't running, it will wait for the app to launch and then attach.

如果应用程序已经在运行,调试器将附加到正在运行的进程。如果它没有运行,它将等待应用程序启动然后附加。

回答by Adam Johns

I'll leave this here since neither of the other 2 answers gave me quite enough detail without a little bit of a struggle.

我将把这个留在这里,因为其他 2 个答案都没有给我足够的细节而没有一点挣扎。

  1. Run your app in the simulator and take note of the name in the Debug navigator enter image description here

  2. Plug in your device and don't forget to select your device as the target enter image description here

  3. Debug > Attach to Process > By Process Identifier (PID) or Name enter image description here
  4. Enter the name from step 1 and attach. That should be all you have to do. enter image description here
  1. 在模拟器中运行您的应用程序并记下调试导航器中的名称 在此处输入图片说明

  2. 插入您的设备,不要忘记选择您的设备作为目标 在此处输入图片说明

  3. 调试 > 附加到进程 > 按进程标识符 (PID) 或名称 在此处输入图片说明
  4. 输入步骤 1 中的名称并附加。这应该就是你所要做的。 在此处输入图片说明

回答by PiTheNumber

In Xcode 5.0.1 and 6 it's the menu bar items:

在 Xcode 5.0.1 和 6 中,它是菜单栏项:

Debug > Attach to Process > By Process Identifier (PID) or Name...

回答by Japes

In Xcode 7 it's just:

在 Xcode 7 中,它只是:

Debug > Attach to Process by PID or Name...