Dmitry L.
Dmitry L.

Reputation: 138

How to create few apps in one bundle?

I have an application that runs as an agent and has icon in the top bar. It should be able to run another app with window and icon in the dock. Both should to share same core data. Is there way to do it? How to open one app from another? Thank you.

Upvotes: 0

Views: 54

Answers (1)

Sega-Zero
Sega-Zero

Reputation: 3017

Create a new cocoa application target, then add Copy Files build phase that embeds your subproject target into main app bundle: enter image description here

Launch your embedded binary with NSTask class with code like this:

NSString *executablesPath = [[[NSBundle mainBundle] executablePath] stringByDeletingLastPathComponent];
NSBundle *subProjBundle = [NSBundle bundleWithPath:[executablesPath stringByAppendingPathComponent:@"subproject.app"]];
NSTask *subBinaryTask = [[NSTask alloc] init];
subBinaryTask.launchPath = [subProjBundle executablePath];
[subBinaryTask launch];

Upvotes: 2

Related Questions