Giving Command line arguments in Xcode in C program

CXcodeCommand Line

C Problem Overview


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

C Solutions


Solution 1 - C

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.

Solution 2 - C

Keyboard shortcut is commandshift<

Solution 3 - C

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.

Solution 4 - C

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

Solution 5 - C

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

Solution 6 - C

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionitsaboutcodeView Question on Stackoverflow
Solution 1 - CjengelsmaView Answer on Stackoverflow
Solution 2 - CSteve YostView Answer on Stackoverflow
Solution 3 - CCarl NorumView Answer on Stackoverflow
Solution 4 - CHany SakrView Answer on Stackoverflow
Solution 5 - CDeepak Kr GuptaView Answer on Stackoverflow
Solution 6 - CPrakash SinhaView Answer on Stackoverflow