Piping into an app running under Xcode

I am trying to debug a C command line application using Xcode on OS X Lion. An application requires a lot of input through standard input. In the shell, I simply paste the text file into this application.

How can I do this using Xcode?

+3
source share
3 answers

Just for a better explanation of @Nestor's answer ....

I could not figure out how to connect to the x-code, so I added the following code at the beginning of my script, which was sent from a test file called a test file.

    // For debugging
if (argc == 2 && strcmp(argv[1], "debug") == 0 ) {
    printf("== [RUNNING IN DEBUG MODE]==\n\n");
    char test_file_path[] = "/Users/bonobos/are/amazing/test.txt";
    freopen(test_file_path, "r", stdin);
}

, , xcode - , , , .

freopen stdin.

, if, xcode, debug. , , realsies.

xcode, :

> a > Change Scheme

"debug" :

add debug argument

+2

Xcode .

. Stackoverflow here.

( ):

Xcode 4.5.1:

  • ( → ...)
  • " "
  • "" "" "" ", MyApp.app "
  • "", . ( Xcode " MyApp" )
  • - . ( - /Users/user/Library/Developer/Xcode/DerivedData/MyApp - dmzfrqdevydjuqbexdivolfeujsj/Build/Products/Debug/)
  • , , , :

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

  • Xcode, .

+2

You cannot, unfortunately. I need to change my program to read from a file for debugging purposes, for example:

    NSFileHandle *input;

    if (AmIBeingDebugged())
        input = [NSFileHandle fileHandleForReadingAtPath:@"/Users/me/debug.input"];
    else
        input = [NSFileHandle fileHandleWithStandardInput];

The source for AmIBeingDebugged is here .

+1
source

All Articles