Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to embed an executable in my project

I would like to embed a command-line executable in my Xcode/Cocoa project, to then start it with NSTask. Which path should I use in the setLaunchPath ?

Thanks !

like image 291
Laurent Crivello Avatar asked Feb 04 '12 22:02

Laurent Crivello


People also ask

Can you embed an EXE in HTML?

No, it's not possible.

Can you embed an EXE in a PDF?

Adobe Acrobat allows you to attach, or bind, an EXE file with a PDF file. However, for security reasons, EXE files cannot, by default, be saved or opened with Acrobat.


1 Answers

you should add it to your resources folder. Then, in runtime, read the app's resource bundle path, and append the name of the executable (including subfolders if you add it to a folder inside the resource bundle)

For instance:

NSString *execPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"binaryname"];

NSTask *task = [[NSTask alloc] init];

[task setLaunchPath: execPath];
like image 163
Ernesto Avatar answered Nov 15 '22 09:11

Ernesto