How to embed an executable file in my project

I would like to embed a command line executable in my Xcode / Cocoa project to run it using NSTask. Which way should I use in setLaunchPath?

Thank!

+5
source share
1 answer

You must add it to your resources folder. Then, at runtime, read the path of the application resource package and add the name of the executable file (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];
+7
source

All Articles