如果您转到 /usr/bin
,您将看到数百个可执行文件或指向可执行文件的链接。
我的应用程序(在 Xcode 中用 Obj-C 编写的 Mac 应用程序)依赖于其中一些可执行文件。不幸的是,可执行文件必须手动安装 - 我必须检查它们,然后提示用户安装它们。
我的代码是:
NSTask *task = [[NSTask alloc] init];
[task setLaunchPath:@"/usr/bin/executable"];
NSPipe *pipe = [NSPipe pipe];
[task setStandardOutput:pipe];
NSFileHandle *file = [pipe fileHandleForReading];
[task setArguments:[NSArray arrayWithObjects:sender, target, nil]];
[task launch];
我想知道是否可以将我的应用程序中的可执行文件复制到某处,然后从那里调用它。这样一来,用户就不必亲自购买。
Mac App Store 会允许吗?
最佳答案
如果您想知道,在 Swift 3 中您可以这样做:
let bundle = Bundle.main
let task = Process()
let path = bundle.path(forResource: "executableName", ofType: "")
task.launchPath = path
关于objective-c - 在 Mac 应用程序中嵌入可执行文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12012783/