Adam Bunch
Adam Bunch

Reputation: 113

How to launch a Command Line Tool from app in Swift?

How does one invoke a command line tool from an app? I'd like to package the app with the command line tool and be able to launch it when the app launches.

When I try to use

func openCommandLineTool() {
    NSWorkspace.shared.open(URL(fileURLWithPath: "/filepath/"))
}

It tells me the application does not have permission to launch the command line tool.

My goal is to have an app that only launches the command line tool. How can I build this command line tool into the app? Is it possible?

Upvotes: 1

Views: 1288

Answers (1)

Adam Bunch
Adam Bunch

Reputation: 113

I solved this by going to the .entitlements file within Xcode and selecting 'NO' for both 'App Sandbox' and 'com.apple.security.files.user'.

Upvotes: 2

Related Questions