[英]Running terminal commands from Cocoa App in Swift failing: “command not found” but works using Command Line Tool in swift
[英]How to launch a Command Line Tool from app in Swift?
如何从应用程序调用命令行工具? 我想使用命令行工具打包该应用程序,并能够在应用程序启动时启动它。
当我尝试使用
func openCommandLineTool() {
NSWorkspace.shared.open(URL(fileURLWithPath: "/filepath/"))
}
它告诉我该应用程序无权启动命令行工具。
我的目标是拥有一个仅启动命令行工具的应用程序。 如何在应用程序中构建此命令行工具? 可能吗?
我通过转到Xcode中的.entitlements文件并为“ App Sandbox”和“ com.apple.security.files.user”都选择了“ NO”来解决此问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.