Question

I'd like to be able to pass command line arguments to programs that are run/debugged under Xcode. I want to do this so that I can command-line enable debug modes using Cocoa's NSUserDefaults and NSArgumentDomain.

How to do that?

Thanks!

Was it helpful?

Solution

Xcode 4

Command line arguments can be set in schemes in Xcode 4. In the scheme editing window, the list of possible actions, such as Build, Run and Test are displayed on the left hand side. Select the Run action for the scheme you are setting the command line arguments for, then add the argument(s) in the 'Arguments Passed On Launch' section.

Pre-Xcode 4

In the left-hand sidebar, expand the Executables section, then right-click the executable you want to have arguments and hit Get Info. Go to the Arguments tab - it has two sections you can use:

  • Arguments, for command-line arguments you want sent to your program
  • Environment, for variables you want set in the environment before your program launches
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top