开发者

Xcode: Multiple targets in same bundle

I have an Xcode project with a Cocoa application target and a shell tool target. These projects share a Core Data persistent store and thus I am hoping to have both projects use the same *.mom file.

To allow this and to simplify deployment I would like the terminal app to to placed inside the Cocoa app bundle and then have both executables access the same *.mom file from inside the bundle.

Is it possible to setup the Xcode project so that the terminal app gets placed inside the Cocoa app bundle and then have the terminal app load the main bund开发者_如何学编程le of the Cocoa app to get the path of this shared *.mom ?


You should be able to do what you want.

  1. Make the Cocoa app target dependent on the terminal app target: click on the Cocoa target, Get Info, General Tab, and click the "+" under the Direct Dependencies pane, and select the terminal target.

  2. Add a "Copy Files" build phase to your Cocoa target: right-click on the target, Add -> New Build Phase -> New Copy Files Build Phase. You'll get an information window where you can pick the destination of the copy; I recommend "Resources", the default.

  3. Drag the terminal app build product (from the "Products" folder in the project navigation pane) onto the Copy Files build phase you just created. This will cause the terminal app to be copied into the Cocoa app's resource folder, which is where your .mom file lives by default, at build time.

  4. In your Cocoa code, you can find the path or URL to the terminal app by querying the main bundle for the path to the resource with the terminal app's name and extension. Your terminal app will need to discover the directory that it is launched from to find the .mom file in the same directory.

Hope this is helpful.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜