81

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

itsaboutcode
  • 24,525
  • 45
  • 110
  • 156
  • 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 – 4lex1v Nov 18 '12 at 13:52
  • 5
    Note: the accepted answer is out of date. see @jengelsma's below. – chmullig Oct 06 '13 at 02:56
  • 2
    accepted answer is still out out of date. It would really be helpful to others if you could switch it. – masukomi Feb 23 '16 at 13:30

6 Answers6

159

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.

jengelsma
  • 8,192
  • 4
  • 21
  • 21
45

Keyboard shortcut is commandshift<

Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140
Steve Yost
  • 725
  • 6
  • 5
37

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.

Justin
  • 447
  • 4
  • 10
  • 33
Carl Norum
  • 219,201
  • 40
  • 422
  • 469
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

vivek_bye
  • 7
  • 4
Hany Sakr
  • 2,591
  • 28
  • 27
13

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

Daksh Gupta
  • 7,554
  • 2
  • 25
  • 36
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