Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

passing command line arguments (NSArgumentDomain) to program under Xcode

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!

like image 353
jeff7091 Avatar asked Feb 26 '26 04:02

jeff7091


1 Answers

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
like image 188
Tim Avatar answered Mar 01 '26 12:03

Tim



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!