85

I am solving my C assignment in Xcode and in that program i have to give command line arguments when running the program and for this i have to user terminal like this:

./a.out myfirstCommand mySecondCommand

I was wondering if it possible to give these kind of commands within xcode instead of going to terminal. Thanks

3
  • And as of XCode 4.3 Command-Line Tools are not bundled with XCode, so you should go to your prefs on Download tab, and click install Command-Line Tools plugin Commented Nov 18, 2012 at 13:52
  • 5
    Note: the accepted answer is out of date. see @jengelsma's below. Commented Oct 6, 2013 at 2:56
  • 2
    accepted answer is still out out of date. It would really be helpful to others if you could switch it. Commented Feb 23, 2016 at 13:30

6 Answers 6

163

As of Xcode 4.x I've had to go to the Product menu, select "Edit Scheme", then select the arguments tab and add the arguments there.

Sign up to request clarification or add additional context in comments.

5 Comments

+1 Thanks for reviving this thread to give an updated answer! I noticed you followed up after over a year, which is impressive :)
Works in XCode 5.1 too. Shortcut: Cmd-<
@itsaboutcode Please mark this one as an answer also. It is allowed to have more than one answer to a stackQuestion.
Also Option + clicking Run button will open this dialog.
Xcode 10.2: "Product -> Scheme -> Edit Scheme..." was the menu path for me. command+shift+< and option+clicking Run also still work.
46

Keyboard shortcut is commandshift<

Comments

38

Pre Xcode 4.x
Right click the executable in your Xcode project and pick "Get Info". Then pick the "arguments" tab and you can set arguments to pass when you run or debug your program from inside Xcode.

Xcode 4.x or later
Go to the Product menu, select "Edit Scheme", then select the arguments tab and add the arguments there.

2 Comments

this is old and deprecated! No "Get Info" option with right click to exec.
Please update outdated answer. Right click the executable in your Xcode project means nothing for those who see XCode for the first time.
24

In Xcode 8.x just select the project from the title bar and select Edit Scheme (not schema), then select the Run debug and select the Arguments Tab from the popup window.

enter image description here

enter image description here

1 Comment

Confirming it's still the same in Xcode 9 as Hany's answer.
15

In Xcode 12.3 You can do the following

Menu Item Product -> Scheme -> Edit Scheme -> Arguments Tab -> Arguments Passed on Launch

enter image description here

enter image description here

1 Comment

I don't know why but, didn't work for XCode 12.5.1
1

For XCode v12.5.1, you can pass additional/launch run argument by following action-

  1. Goto edit scheme by "Product>Scheme>Edit Scheme" or by using keyboard shortcut key "CMD+Shift+<"
  2. Then switch to Arguments tab on open dialog box
  3. Here you can pass required launch arguments

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.