如何将stdin从文件传递到Xcode 4+中的可执行文件? [英] How can I pipe stdin from a file to the executable in Xcode 4+?

查看:51
本文介绍了如何将stdin从文件传递到Xcode 4+中的可执行文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个mpi程序,并设法通过Xcode 4进行编译和链接. 现在,我想使用Xcode 4对其进行调试.

I have an mpi program and managed to compile and link it via Xcode 4. Now I want to debug it using Xcode 4.

如何从文件中将标准输入传递给程序?

How can I pipe the standard input to the program from a file?

在终端中,我会输入

mpirun -np 2 program < input.txt

我能够在Scheme编辑器的"Info"面板中运行定义自定义可执行文件(mpirun)的程序,我也知道我可以在"Arguments"面板中传递参数.但是,即使我选中使用自定义工作目录"并在选项"面板中添加输入脚本的正确目录,Xcode 4似乎也不接受< input.txt"作为参数.

I am able to run the program defining a custom executable (mpirun) in the "Info" panel of the Scheme editor, I also know that I can pass arguments in the "Arguments" panel. But Xcode 4 does not seem to accept "< input.txt" as an argument, even if I check "Use custom working directory" + add the correct directory of the input script in the "Options" panel.

本文说可以使用<输入".txt"作为参数,但我想它可以在Xcode 2或Xcode 3中使用,但似乎在Xcode 4中不再可用.

This article Says it is possible to use "< input.txt" as an argument, but I guess that worked in Xcode 2 or Xcode 3, but it does not seem to work in Xcode 4 anymore.

推荐答案

在Xcode 4.5.1中:

In Xcode 4.5.1:

  1. 打开方案编辑器(产品菜单->编辑方案...)
  2. 选择运行调试"方案
  3. 在信息"标签面板中,将启动"单选按钮选择从自动"更改为等待MyApp.app启动"
  4. 关闭方案编辑器
  5. 按运行"按钮以构建并运行目标. (工具栏中Xcode的状态窗口将显示正在等待MyApp启动")
  6. 启动终端并cd到您构建的应用程序的文件夹. (这将类似于/Users/user/Library/Developer/Xcode/DerivedData/MyApp-dmzfrqdevydjuqbexdivolfeujsj/Build/Products/Debug/)
  7. 以任何您想要的标准输入方式启动应用程序管道:

  1. Open the scheme editor (Product menu -> Edit Scheme...)
  2. Select the Run Debug scheme
  3. In the 'Info' tab panel, change the 'Launch' radio button selection from 'Automatically' to 'Wait for MyApp.app to launch'
  4. Close the scheme editor
  5. Press the Run button to build and run your target. (Xcode's status window in the toolbar will show 'Waiting for MyApp to launch')
  6. Launch Terminal and cd to your built application's folder. (It will be something like /Users/user/Library/Developer/Xcode/DerivedData/MyApp-dmzfrqdevydjuqbexdivolfeujsj/Build/Products/Debug / )
  7. Launch your app piping in whatever you want into standard input:

echo mydata | ./MyApp.app/Contents/MacOs/MyApp

  • 切换回Xcode,调试器将检测到您的应用程序启动并将其附加.

  • Switch back to Xcode and the debugger will have detected your application's launch and attached to it.

    这篇关于如何将stdin从文件传递到Xcode 4+中的可执行文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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