Re: Include an executable without hard coding the path
Re: Include an executable without hard coding the path
- Subject: Re: Include an executable without hard coding the path
- From: Marco S Hyman <email@hidden>
- Date: Fri, 17 Jul 2009 21:37:35 -0700
On Jul 17, 2009, at 8:38 PM, Rick Schmidt wrote:
need to include an executable in my project when it runs. I right
clicked my project and added an existing file pointing to the
executable, but how to I reference it in my code without a hard coded
full file path to my local drive?
Guess: put the executable in with your resources and grab it with
...
[task setLaunchPath: [[NSBundle mainBundle]
pathForResource:@"blastcl3" ofType:nil]];
...
That assumes you are only building for one architecture. You'll
need to do some extra stuff to support more.
Also, I'm assuming that you have the rights to distribute the
executables that you need. If not, then make the location
of the executables a preferences item. I do that with one
of my apps. I use a convenience function to grab the needed
data.
[task setLaunchPath: [MyPrefs pathToApp]];
MyPrefs is my class to handles app preferences. I initialize the
default values with the most likely location, /usr/bin or /opt/local/
bin,
etc., so it works for most folks without having to open a preference
panel.
/\/\arc
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden