ed1t
ed1t

Reputation: 8699

Run a binary from .app's package contents

Can I have the binary files like .sh as part of the .app in "Package Contents".

I basically have .app which has 2 buttons start/stop which basically kicks off a process to start the server. To keep everything clean, I would like to store the start/stop shell scripts within the .app.

Can I execute those shell scripts from .app?

Upvotes: 1

Views: 428

Answers (2)

Joe Osborn
Joe Osborn

Reputation: 1155

Yes. You'll want to look at NSTask to run your scripts or other binaries, and find the files using NSBundle's API.

Upvotes: 1

Noah Witherspoon
Noah Witherspoon

Reputation: 57139

On the Mac, yes: use the NSTask class’s +launchedTaskWithLaunchPath:arguments: method (for example), after retrieving the path to the binaries with one of the methods on NSBundle’s—-resourcePath, -bundlePath, -pathForResource:ofType:, or whatever.

On iOS... no. NSTask isn’t available.

Upvotes: 1

Related Questions