4

I'm trying to pass arguments to my Xcode C++ command-line tool. I think I'm following the help, and the answers I've found on Stack Overflow, but I'm not having any luck.

I'm using Xcode 7.2.1. I've edited the scheme to have two command-line arguments (an input file and an output file.) I've posted a screen shot of the editor below.

When I run the code, it doesn't find the arguments. (I don't mean that it can't find the files on disk. The program aborts because argc is 1 instead of 3.)

Can you tell me what I'm doing wrong?

EDIT: After playing around with it in response to the advice I received, it suddenly worked. I have no idea what changed. It works now with the dialog looking exactly like the screenshot I posted originally.

enter image description here

3
  • That works well for me, are you sure that you are using the scheme you edited? Commented Aug 22, 2016 at 19:52
  • @Jean-Baptiste Perhaps not; how do I tell? Commented Aug 22, 2016 at 19:53
  • In the dropdown have a look at the scheme you use, and edit the corresponding scheme. Hard to tell you more here. Commented Aug 22, 2016 at 19:55

1 Answer 1

1

I'd suggest that you use only one argument set at a time. Each one of the checked lines represents a command line, not a single argument, so put both of your arguments on a single line, as in

$PROJECT_DIR/detroit.txt $PROJECT_DIR/detroit.out
Sign up to request clarification or add additional context in comments.

4 Comments

Thanks, but that was actually the first thing I tried. I've tried it again, and I still have argc = 1.
Wrong, each "line" represent arguments passed... Checkbox are here to exclude some.
@ Jean-Baptiste I changed it back to one argument per line and it worked! It now looks exactly like the screenshot I posted. The only difference is that it works now. I have no idea what changed. Thanks for your help.
I guess if it happens again, save the Xcode project file(s), copy them to a different location, change it to two arguments and back to one again (or whatever fixes it), then save the project again, and then you can do a diff between the "good" and "bad" versions of the project to see what actually changed.

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.