View Full Version : running command line progs in Xcode
Dec 4, 2010, 07:07 PM
I'm writing simple C command line programs as exercises in Xcode.
They require input arguments at startup ( the char * argv in main.c).
Is there a way to run the programs in Xcode rather than the Mac system terminal? The Debug console just seems to run programs without arguments and accept arguments while the program is running (such as from getchar or scanf), but how can I use it to enter the arguments at startup?
I can't get the programs to run from the terminal either. I don't want to have to compile and go to the terminal every time I test the program.
If I can run the startup commands from within Xcode that would be nice.
Dec 4, 2010, 07:37 PM
Under Executable Environments it mentions command line arguments, and there's a screenshot that shows the dialog box (though not with the arguments tab selected).
It does seem substantially easier to do this by running from terminal if you wish to run with different arguments frequently. Then again, I would advocate vim/gcc/run-from-terminal/gdb when learning C. An IDE will only confuse at this stage.
Dec 4, 2010, 07:51 PM
Thanks for your reply.
I did get the environment arguments in the executable to work, though it is a bit clunky to use.
I would not mind using the terminal if I could get it to work.
Even if I cd to the path where my build product is located and try to run the program by entering the build product name and arguments, I just get "command not found". Is the product not yet an executable?
I'm fine using Xcode for simple C dev since I am also concurrently learning Objective C and testing iPhone programs as well.
Dec 4, 2010, 08:29 PM
The problem you're having in terminal is caused by . (the current directory) not being in your PATH (the environment variable that tells your shell where to look for programs when you don't give a full path). This is for your own safety, so don't add it.
To run your program when you are in the same directory:
Where myprog is your target name.
Dec 4, 2010, 08:52 PM
Thanks. That works.
Its embarrassing. I've worked in computer digital effects for 14 years under unix and linux, and written software tools for 3d programs, and I still don't know even the most basic rules for working in the shell.
I never had to work in the shell except for navigating directories.
Some types of computer work are so insular that you never have to think about anything else.