On Oct 5, 2011, at 6:18 PM, cptkrf wrote:

> In Xcode 3, I would put the scripts and data in (jobfolder)/build/debug and 
> call it, as with --- int result = system("./perlscript.pl");   Worked fine.

That may have worked, but it’s kind of bass-ackwards, if you’ll excuse my 
French. The build/ folder is for the output of building; you shouldn’t put any 
source files in there yourself.

If you want a file to become part of the app, add it as a resource to the 
target and it will be copied in. I’m not sure exactly where it goes if you 
build a plain command-line target, but if you build some flavor of application 
it will go into the Contents/Resources subdirectory. The way to find such a 
file is something like
        NSString* path = [[NSBundle mainBundle] pathToResource: @“perlscript” 
ofType: @“pl”];

It would be better to use NSTask to run the script instead of calling system(). 
For one thing, it plays better with NSString, and more importantly, it doesn’t 
parse its input as a command line so it won’t fail if the app is run from a 
location whose path contains a space character. (There was, infamously, an 
early iTunes installer that made a similar mistake and ended up erasing your 
home directory if the name of your disk had a space in it.)

—Jens_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to