ios Xcode 内的终端窗口?

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

Terminal window inside Xcode?

iosxcode

提问by Adam Johns

Does Xcodehave an area I can open up a terminal shell session insideXcode? Android Studiohas a window you can open up at the bottom by the console logcatwindow that will start a terminal session. Does Xcodehave anything like this?

是否Xcode有一个区域,我可以打开一个终端shell会话XcodeAndroid Studio有一个窗口,您可以通过控制台logcat窗口在底部打开该窗口,该窗口将启动终端会话。是否Xcode有这样的事?

采纳答案by RaffAl

Unfortunately there is no such a thing in Xcode. We have to fall back to external Terminalwindow.

不幸的是,在Xcode. 我们必须退回到外部Terminal窗口。

If you really want to do it, you can add a build phase and run script that opens the Terminal- but that might not be what you are looking for.

如果你真的想这样做,你可以添加一个构建阶段并运行脚本来打开Terminal- 但这可能不是你想要的。

enter image description here

在此处输入图片说明

回答by Aleksei Minaev

  1. Create executable shell script with the following contents and save it anywhere

    #!/bin/bash
    open -a Terminal "`pwd`"
    
    • Add execute permissions to your script: $ chmod +x <YourShellScript>
  2. In the Xcode menu bar, Go to Xcode -> Preferences -> Behaviors.
  3. Add a Custom behavior
  4. Name it "Open Terminal", or whatever.
  5. (Optional) Configure a hotkey for the behavior by tapping on the ?
  6. (Optional) Input hotkey combination
  7. Checkmark Run, select you script from step 1.
  8. Use it within Xcode.
  1. 使用以下内容创建可执行的shell脚本并将其保存在任何地方

    #!/bin/bash
    open -a Terminal "`pwd`"
    
    • 为您的脚本添加执行权限: $ chmod +x <YourShellScript>
  2. 在 Xcode 菜单栏中,转到 Xcode -> Preferences -> Behaviors。
  3. 添加自定义行为
  4. 将其命名为“打开终端”或其他名称。
  5. (可选)通过点击 ?
  6. (可选)输入热键组合
  7. 选中运行,从步骤 1 中选择您的脚本。
  8. 在 Xcode 中使用它。

Image with numbers corresponding to steps

带有与步骤对应的数字的图像

回答by mackworth

Relatedly, now in Xcode 8, you can have your program run automatically in Terminal rather than using the Xcode Console. Just go to Edit Scheme > Run > Options and set Console at the bottom to Terminal.

相关地,现在在 Xcode 8 中,您可以让程序在终端中自动运行,而不是使用 Xcode 控制台。只需转到“编辑方案”>“运行”>“选项”,然后将底部的“控制台”设置为“终端”。