tomato_soup
tomato_soup

Reputation: 354

How can I use Xcode to compile a C program so I can use the binary in the sandbox?

I have a Cocoa app that runs a binary executable I include with the project, unless I turn sandboxing on. I want sandboxing on, so I need a way to authorize the running of this program. I have the source code - this binary executable is part of a big package which comes with a shell script for making the software along with a bunch of other programs. It compiles successfully using this script on my Mac.

I found another post on stackoverflow where it was suggested that the C code can be compiled within XCode along with the rest of the app and it will be allowed to execute that way.

Is that true? I would like to compile the C code as part of my app and run the binary executable it creates.

Upvotes: 0

Views: 521

Answers (1)

tomato_soup
tomato_soup

Reputation: 354

I got it.

As suggested by trojanfoe, codesigning worked.

codesign -s "Me" theBinary

the problem was my Swift line,

Bundle.main.url(forAuxiliaryExecutable: "theBinary")

I changed it to,

Bundle.main.url(forResource: "theBinary", withExtension: nil)

and now it works. Alright! Only cost me $99.

Upvotes: 1

Related Questions