0

My XCode project has two targets, a main SwiftUI application, and a helper command line program written in C++. How do I include the helper program in my application bundle, and what would be the path to the helper executable? I want to do something like this in my application:

let process = Process()
process.executableURL = URL(fileURLWithPath: "/pathToHelper/helper")
try process.run()

What is "pathToHelper" and is it different when running from XCode and when running the installed application?

HangarRash
  • 7,314
  • 5
  • 5
  • 32
mstrsn
  • 21
  • 3
  • Does this answer your question? [How to include an external executable into a MacOS app?](https://stackoverflow.com/questions/71788005/how-to-include-an-external-executable-into-a-macos-app) – Swift Dev Journal Mar 30 '23 at 23:41

1 Answers1

0

Thanks @swift-dev-journal for pointing me in the right direction. I ended up following the directions to embed my helper in my app here, and then getting the path to the helper like this:

let process = Process()
let helper = Bundle.main.path(forAuxiliaryExecutable: "helper")
process.executableURL = URL(fileURLWithPath: helper!)
try process.run()
mstrsn
  • 21
  • 3