title: Find out location of an executable file in Cocoa
body: <p>The simple question is: how to find out the location of an executable file in a Cocoa application. </p>
  
  <p>Remember that, in many Unix-like OS people use PATH environment to assign the preferred location for their executables, especially when they have several versions of same application in their system. As a good practice, our Cocoa application should find the PREFERRED location of the executable file it needs.</p>
  
  <p>For example, there was a SVN 1.4 in Leopard default configuration at /usr/bin, and you installed a much newer version, say SVN 1.5.3 via MacPorts at /opt/local/bin. And you set your PATH using /etc/path.d or .bash_profile or .zshrc like that:</p>
  
  <p>export PATH=/opt/local/bin:$PATH</p>
  
  <p>So you can use the new version of svn instead of the old one from the system. It works well in any terminal environment. But not in Cocoa applications. Cocoa application, as far as I know, only has a default PATH environment like this:</p>
  
  <p>export PATH="/usr/bin:/bin:/usr/sbin:/sbin"</p>
  
  <p>By default it will not using the configuration in /etc/path.d, .bash_profile, .profile, .zshrc, etc.</p>
  
  <p>So how exactly can we do?</p>
  
  <p>p.s. We have <a href="http://github.com/pieter/gitx/tree/master/PBGitBinary.m" rel="noreferrer">a semi-solution here</a>, but it cannot fully satisfied the objective for this question.</p>