Thanks a lot. I tried this in my app A , but I keep getting the error message
launch path not accessible together with a stack trace. I am getting the url to my app B like this: url_ = NSWorkspace.shared.urlForApplication( withBundleIdentifier: "de.zach.AppB" ) which points to /private/tmp/Debug/AppB.app (which is correct ). I thought, maybe, because of sandboxing, I have to ask the user to open the path to app B , so that I get the permission. So, when launching the sub-process, I tried this: let process = Process() process.standardOutput = FileHandle.nullDevice process.standardError = FileHandle.nullDevice let oPanel = NSOpenPanel() oPanel.allowsMultipleSelection = false oPanel.canCreateDirectories = false oPanel.canChooseFiles = true oPanel.directoryURL = url_ let result = oPanel.runModal() let path_to_exec = oPanel.url!.path NSLog( "path_to_exec = %@", path_to_exec ) process.launchPath = path_to_exec process.arguments = [""] process.launch() In the OpenPanel, I navigate to the executable in .../Contents/MacOS/BApp. It prints the correct path_to_exec, but the launch() fails. I have also tried this variation: oPanel.directoryURL = url_ let result = oPanel.runModal() let path_to_exec = oPanel.url!.path + "/Contents/MacOS/ArtSaverApp" where I don't navigate into the app bundle, but let app A append the sub-path to the executable. Same result ("not accessible"). I have set the Capability "User Selected File" to read&write in the App Sandbox in Xcode, but that did not change the outcome. I also tried to launch app B by executing a shell command in app A, like this: process.launchPath = "/bin/bash" process.arguments = ["-c", "open", url_!.path, "-f"] process.launch() But that did nothing. No app B appeared, and no error message in app A. > On 21. Jun 2020, at 02:04, Marco S Hyman <m...@snafu.org> wrote: > > > >> On Jun 20, 2020, at 4:31 PM, Gabriel Zachmann <z...@cs.uni-bremen.de> wrote: >> >>> >>> If app B can be treated as a sub-process of app A you can use Process. I >>> know that argument passing works with Process. >> >> Sounds good. How can A launch B as its sub-process? (and pass command line >> arguments?) >> >> > > let process = Process() > process.standardOutput = FileHandle.nullDevice > process.standardError = FileHandle.nullDevice > process.launchPath = url.path // path to app > process.arguments = [“arg1”, “arg2”, “arg3”] > process.launch() > > and if you need to > > process.waitUntilExit() > > Obviously don’t wait on the main thread! > > I do this in an app where the URL points to a helper located in the bundle. > Not sure what extra hoops you’d need to jump through to launch an app outside > of the sandbox. Probably needs user approval which can be remembered using > a security scoped bookmark.
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com