2

I wrote a simple C++ program that requires some input to run. In the terminal I simply run in ./myProgram < fileWithData.txt. However I could not figure out how to specify and input file for the target executed in Xcode. I used the command line project. Of course I could use a different target, for example run Terminal.app and then pass it the executable with the input file but then I can no longer debug it.

This question: Cannot get lldb to read file input explains how to set the input path in lldb, but I could not find a way to specify lldb commands that are executed before the process is started.

Community
  • 1
  • 1
Nils
  • 13,319
  • 19
  • 86
  • 108
  • 2
    For cases like this, I temporarily set the program to open the test input file and that instead of `stdin` or `std::cin`. Alternatively, add a command line option to set the input file and use `stdin` as the default. – Khouri Giordano May 20 '17 at 16:36

1 Answers1

1

I don't think there's a way to do this entirely from within Xcode. However if you set the Run Scheme in Xcode to the launch mode "Wait for executable to be launched," hit run, and then run your program from Terminal.app with the appropriate piping, the Xcode-embedded lldb will connect to it.

pmdj
  • 22,018
  • 3
  • 52
  • 103