Xcode 4: Adding Command-Line Arguments and Environment Variables

March 28th, 2011

Filed under: Xcode | 3 comments

Choose Edit Scheme from the Scheme pop-up menu in the project window toolbar to open the scheme editor. Select Run from the list on the left side of the scheme editor. Click the Arguments button in the scheme editor.

Xcode 4 Command Line Arguments

From here you can add command-line arguments and environment variables. Clicking the Diagnostics button provides checkboxes for commonly-used environment variables.

Tags:


3 thoughts on “Xcode 4: Adding Command-Line Arguments and Environment Variables

  1. Derrick says:

    I had been searching the web to find out how you can you use pipes/ioredirection with Xcode 4.
    in terminal i could write
    ./exec1 < textfile | ./exec2

    and it would run as it should.
    so i tried to add in the arguments in Xcode, but it doesn't have the same effect.
    After experimenting, I discovered that all those arguments are passed in as a char*
    which means that you won't get the piping power you would if you entered in the
    commandline arguments.

    Some people chose to modify their programs in order to get the same functionality,
    But I refused to stop there. I found solution that somewhat works and I hope it helps
    someone out there. You basically have to modify an custom makefile

    http://embsi.blogspot.com/2012/02/io-redirection-and-pipes-in-eclipse.html

  2. Eric says:

    Is there a way to do this on Xcode 3.2.6? I’d prefer not to have to switch to Lion just to be able to pass command-line arguments to my program from Xcode.

    • Mark Szymczyk says:

      Eric,

      To set command line arguments in earlier versions of Xcode, select your Executable from the Groups and Files list. Click the Info button in the toolbar (or right-click and choose Get Info) to open the executable inspector. Click the Arguments tab in the executable inspector. From there you can set command line arguments and environment variables.

Leave a Reply

Your email address will not be published. Required fields are marked *