Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Mark FX

macrumors regular
Original poster
Nov 18, 2011
159
17
West Sussex, UK
I have made a command line tool from the project template in Xcode, and have tested it from the IDE and everything is working as it should, the tool requires one argument to excecute, or if no argument is entered it simply returns the version information.

I have made an archive version with a release build. but when I navigate to the excecutable folder in Terminal, and enter the name of the app, the bash shell returns a message saying command not found.
But if I type into the Terminal window "open myAppName" it opens a second teminal window and returns the no argument version info, if I try to use "open myAppName argument" it says that the argument could not be found.
I'm using Xcode 4.52 on OSX 10.7.

Have I missed something in the way you have to build or deploy a command line tool ?

I have never built a command line tool before now, so I have no knowledge
or previous experience with this type of project.

Any help or advise would be much appreciated, Thanks in advance.

Regards Mark
 

ytk

macrumors 6502
Jul 8, 2010
252
5
The "open" command is used to tell the computer to open the application as if you'd double-clicked it in the Finder. That's not really what you want to do. Instead, try invoking the program like this:

Code:
./myAppName argument

The "./" is necessary to locate the executable, because by default Bash only looks in your search path for executables, and for security reasons "." (which represents the current directory) isn't usually included in the search path.
 

peoplevoice

macrumors member
Aug 19, 2008
73
1
PATH environment variable

You need to add the absolute pathname of the directory where your executable is to PATH environment variable or copy your executable in one of the listed directories in the PATH environment variable.

You can type in the command line the following to see the list of current directories in the PATH environment variable: echo $PATH

To change the PATH environment variable: vi $HOME/.profile file and add at the bottom of the file the following line:

export PATH=$PATH:absolutePathnameOfDirectoryWhereYourExecutableIs
 

Mark FX

macrumors regular
Original poster
Nov 18, 2011
159
17
West Sussex, UK
Thanks ytk & peoplevoice.

Yes adding "./" to my Terminal command did indeed run the tool.
I was aware of the $PATH variable to access system wide folders, but as a
UNIX newbie, I did not want to go down the path of changing this setting, just
to test this particular project from the Terminal.

Thanks again.

Regards Mark
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.