Search code examples
objective-cmacosxcode6resourcebundlensbundle

Include exec files in osx app bundle


Ive looked around a bit and cant find the answer I was hoping for, I am new to OSX dev so forgive me if this is a basic question.

Using NSTask I open up an exec file while my OSX is running that does stuff, I have to set a launchPath for this like so self.execFile.launchPath = @"/usr/local/bin/execFile";. This is fine when I'm running it on just my Mac, however, I would like to distribute this app. I am looking for a way to to save the execFile in, from what I gather so far from Googling, the apps bundle and call it from there, that way I can set the launchPath in the code and it would work on any computer. So far Ive only seen talk on how to access the app bundle but I don't know how to save a file there in the first place.


Solution

  • You must create a Copy Files build phase for your application target and add the exec files to the Copy Files build phase. Select your project from the project navigator to open the project editor. Select your application target from the left side of the project editor. Click the Build Phases button at the top of the editor. Choose Editor > Add Build Phase > Add Copy Files Build Phase to add the Copy Files build phase.

    After creating the Copy Files build phase, click the disclosure triangle next to it. From there you can add files to the build phase and choose a location in the app bundle to copy the file. When you build the project, Xcode copies the files in the Copy Files build phase to the app bundle in the location you specified.

    enter image description here