I have a OS X application as a .app package which can reside in any arbitrary location in the filesystem. Is there a way to find the current path of the package programmatic
You should be able to find the location of the .app by [[NSBundle mainBundle] bundleURL];
or [[NSBundle mainBundle] bundlePath];
.
However, you probably want to access resources inside the .app by going through NSBundle
to locate them in most cases (this deals with issues like localization).
Note: If you are planning to modify the application bundle; don't. You should not, can not and must not assume that you have write access to the application bundle; and if you do, something is likely very wrong.
Edit: As a point of interest, if you are writing a C program on OS X and need to find the location of the executable; you can use a non-portable main declaration like so:
int main (int argc, const char *argv[], const char *env[], const char *path[]) {
// path[0] now contains the path to the executable
// NOT PORTABLE! OS X ONLY!
return 0;
}