I have a helper application, which is within my main application's application bundle (in the Resources). I'm not sure how to get the path of the application from inside the bundle and launch it.
I'm not sure I fully understand the question. I think you're saying you have an application (let's call it PrimaryApplication.app) and inside it's Resources directory there is an application you need to launch (let's call it Helper.app). In that case you use NSBundle
's -bundlePath
to get the path to the currently running application, then you append the path to your helper from there. You can use NSWorkspace
to launch the application once you know the path to it.
NSBundle *mainBundle = [NSBundle mainBundle];
NSString *helperAppPath = [[mainBundle bundlePath]
stringByAppendingString:@"/Contents/Resources/Helper.app"];
[[NSWorkspace sharedWorkspace] launchApplication:helperAppPath];
In Core Foundation, CFBundleCopyResourceURL should get you the application's url.
In Cocoa, NSBundle has equivalent pathForResource:ofType:
and URLForResource:withExtension:
methods.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With