2

How may I combine a Commandline Tool and a Cocoa Application into one App using XCode?

Finally I need to show the output of the Commandline Tool (stdout and stderr) to a NSTextBox.

Johann Horvat
  • 1,285
  • 1
  • 14
  • 18
  • At the moment I manually copy the commandline tool into the Application Bundle. Is there a way let this XCode manage automatically? So that a build of the App will add both into the bundle? – Johann Horvat Jul 28 '14 at 09:42
  • You have another project that builds the binary? Or it's a static binary? You have a copy bundle resources build phase? – Wain Jul 28 '14 at 10:00
  • Yes. I currently have two seperate projects. One for the commandline tool (static binary), the other containing the Cocoa App. – Johann Horvat Jul 28 '14 at 10:23

1 Answers1

1

Drag the binary project (or add) as a dependency of the main project. This means that it will always be built before the main projects.

Next add a copy bundle resources build phase (or use an existing one) and drag the binary product from the binary project in. This will copy the resulting binary from the first build into the bundle created by the second build.

To run the binary you need to get its path using NSBundle and then run it using NSTask.

Community
  • 1
  • 1
Wain
  • 118,658
  • 15
  • 128
  • 151