简体   繁体   English

如何使用Xcode编译C程序,以便可以在沙箱中使用二进制文件?

[英]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. 我有一个运行该项目包含的二进制可执行文件的Cocoa应用程序,除非打开沙箱。 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. 我有源代码-该二进制可执行文件是一个大程序包的一部分,该程序包附带一个Shell脚本,可用于制作该软件以及其他程序。 It compiles successfully using this script on my Mac. 它可以在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. 我在stackoverflow上发现了另一篇文章,其中有人建议可以在XCode中将C代码与应用程序的其余部分一起编译,并将允许以这种方式执行C代码。

Is that true? 真的吗? I would like to compile the C code as part of my app and run the binary executable it creates. 我想将C代码编译为我的应用程序的一部分,并运行它创建的二进制可执行文件。

I got it. 我知道了。

As suggested by trojanfoe, codesigning worked. 正如trojanfoe所建议的那样,代码签名有效。

codesign -s "Me" theBinary

the problem was my Swift line, 问题是我的Swift系列,

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. 只花了我99美元。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM