• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Include an executable without hard coding the path
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Include an executable without hard coding the path
      • From: Rick Schmidt <email@hidden>
References: 
 >Include an executable without hard coding the path (From: Rick Schmidt <email@hidden>)

  • Prev by Date: Include an executable without hard coding the path
  • Next by Date: Re: Include an executable without hard coding the path
  • Previous by thread: Include an executable without hard coding the path
  • Next by thread: Re: Include an executable without hard coding the path
  • Index(es):
    • Date
    • Thread