How to get the executable path of a command line tool in Objective C (Foundation framework)?
objective-c
Solution
I'm assuming that by `/Applications/Utils/MyTool`, you mean an application named "MyTool" in the "Utils" directory within the "Application" directory (which is actually the path `/Applications/Utils/MyTools.app`). In that case, you could get the directory in which the application resides (`/Applications/Utils`) with the following bit of code:
NSString *appParentDirectory = [[[NSBundle mainBundle] bundlePath] stringByDeletingLastPathComponent];
Problem
I'm trying to work out a way to identify the executable path of a command line tool in Objective C. Hence, if the executable is /Applications/Utils/MyTool, then that method would return /Applications/Utils I'm using the Foundation framework.