0

Using Xcode 14.0.1, I am working on a Command Line Tool project. As long as the command takes no argument it can be run and tested with the Xcode run button.

But I now want to use some arguments, I therefore need to run the command from a terminal.

Here comes my question:

How do I find the path for the command?

Michel
  • 10,303
  • 17
  • 82
  • 179
  • FYI - you can pass command line options to the program when running from within Xcode if you want to. See https://stackoverflow.com/questions/1698830/giving-command-line-arguments-in-xcode-in-c-program – HangarRash Nov 06 '22 at 04:15

2 Answers2

1

Edited because I misread the original question (see comments): xcodebuild -project yourproj.xcodeproj -showBuildSettings from the location of your project should have that information. Might want to add a | grep TARGET_BUILD_DIR to filter for the output directory. It should be ~/Library/Developer/Xcode/DerivedData/projectname-[random-string]/Build/Products/Debug.

Previous answer about Xcode command line tools: They should be under /Library/Developer/CommandLineTools/usr/bin, but xcodebuild and xcrun at /usr/bin, so should be in your PATH automatically. You can find out for sure with xcode-select --print-path.

Zac Anger
  • 6,983
  • 2
  • 15
  • 42
  • I have carefully looked into your reply, but can't draw a definitive answer from it. In /Library/Developer/CommandLineTools/usr/bin nothing looks like the executable I am looking for. I only see this: 2to3-3.8 dyldinfo easy_install-3.8 pip3.8 pydoc3.8 python3.8. xcodebuild and xcrun are in /usr/bin as you seem to indicate. Executing "xcode-select --print-path" outputs: /Applications/Xcode.app/Contents/Developer I tried to use the find command, but I can't (or don't know how to) find the executable I am looking for. – Michel Nov 06 '22 at 03:47
  • Sorry I think I misunderstood your question; I thought you meant building or running an xcode developer tool, are you trying to run the program that you're building? – Zac Anger Nov 06 '22 at 03:49
  • 1
    `xcodebuild -project yourproj.xcodeproj -showBuildSettings` from the location of your proejct should have that information. Might want to add a `| grep TARGET_BUILD_DIR` to filter for the output directory. I believe it'll be something like `~/Library/Developer/Xcode/DerivedData/projectname-[random-string]/Build/Products/Debug` I don't have the full version of XCode installed right now to double-check this though. – Zac Anger Nov 06 '22 at 03:56
  • @Zac_Anger. Yes, it works. Thanks. I cannot accept your current answer out of the point. But if you want to change it to match your last comment I will be glad to accept it. – Michel Nov 06 '22 at 04:11
0

One way to use arguments for console applications in Xcode is to create them in your project's scheme editor, in the "Arguments" section.

It seems that during development, this option will be even more convenient than switching to the terminal.

open scheme editor

show result in report navigator