Reputation: 1363
Say you want to use functionality or interact with another third-party application. Is it possible to link against an executable in an objective-c project? Can the binary maybe be wrapped inside a framework?
Upvotes: 3
Views: 390
Reputation: 74
You can use an XCode copy files phase to put an additional executable in with your main one, in Your.app/Contents/MacOS, then (let's say you copied grep
) to locate it use [[NSBundle mainBundle] pathForAuxiliaryExecutable:@"grep"]
.
I do it a little differently, for example I have a Python program one of my apps calls (getting the response in plist format which is nice) and I just have it copied into the My.app/Contents/Resources directory and use [[NSBundle mainBundle] pathForResource:@"myScript" ofType:@"py"] to find it.
Which way you do it is, I suspect, a matter of taste. I think it makes sense to put compiled executables in with the main one, and Python/Perl/whatever in Resources. From there it's just a matter of setting up an NSTask
to launch and pipe the aux program's output back into your main executable. More info on that here.
Upvotes: 1