iOS - Xcode 错误:由于系统完整性保护,无法附加到进程

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/39219678/
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-09-15 09:11:03  来源:igfitidea点击:

iOS - Xcode Error: cannot attach to process due to System Integrity Protection

iosswiftxcoderuntime-error

提问by Sazzad Hissain Khan

When I running an application shared extension from XCode run button and then trying to share files, XCode shows the below error frequently. Anyone have any idea whats causing it?

当我从 XCode 运行按钮运行应用程序共享扩展然后尝试共享文件时,XCode 经常显示以下错误。任何人都知道是什么原因造成的?

enter image description here

在此处输入图片说明

Error: "cannot attach to process due to System Integrity Protection"

错误:“由于系统完整性保护而无法附加到进程”

采纳答案by Yash Tamakuwala

System Integrity Protection(SIP) aka rootless is a new security feature in OS X 10.11. By default it disables even the administrator to access/modify the root. Follow these stepsto disable SIP:

系统完整性保护 (SIP) 又名 rootless 是 OS X 10.11 中的一项新安全功能。默认情况下,它甚至禁止管理员访问/修改根。请按照以下步骤禁用 SIP:

  1. Restart your Mac.
  2. Before OS X starts up, hold down Command-R and keep it held down until you see an Apple icon and a progress bar. Release. This boots you into Recovery.
  3. From the Utilities menu, select Terminal.
  4. At the prompt type exactly the following and then press Return:

    csrutil disable
    
  5. Terminal should display a message that SIP was disabled.
  6. From the ? menu, select Restart.

You can re-enable SIP by following the above steps, but using csrutil enableinstead.

  1. 重新启动您的 Mac。
  2. 在 OS X 启动之前,按住 Command-R 并保持按住直到看到 Apple 图标和进度条。释放。这将引导您进入恢复。
  3. 从实用程序菜单中,选择终端。
  4. 在提示符下键入以下内容,然后按回车键:

    csrutil disable
    
  5. 终端应显示 SIP 已禁用的消息。
  6. 来自 ?菜单,选择重新启动

您可以按照上述步骤重新启用 SIP,但csrutil enable改为使用。

回答by l --marc l

In some cases, if you are trying to connect to a "system provided" executable (for example, Terminal.app) there is a workaround by making a copy of such executable. The copy will be checked by SIP as "user installed" instead of "system provided".

在某些情况下,如果您尝试连接到“系统提供的”可执行文件(例如,Terminal.app),则可以通过制作此类可执行文件的副本来解决。SIP 将检查副本为“用户安装”而不是“系统提供”。

For an example, see "Launching the Terminal app from Xcode on OS X with System Integrity Protection"

有关示例,请参阅 “在具有系统完整性保护的 OS X 上从 Xcode 启动终端应用程序”

回答by Ricardo Barroso

Sometimes I also get this error on Xcode while trying to run an app on simulator. Usually I only run the app again, and at most I restart the simulator, and it solves the problem.

有时,当我尝试在模拟器上运行应用程序时,我也会在 Xcode 上遇到此错误。通常我只再次运行该应用程序,最多重新启动模拟器,它就解决了问题。

Be aware of the security risks you're incurring on disabling SIP (System Integrity Protection): https://support.apple.com/en-us/HT204899

请注意禁用 SIP(​​系统完整性保护)会带来的安全风险:https: //support.apple.com/en-us/HT204899