Bundle.main.url(forAuxiliaryExecutable) -> URL?

I stumbled across this in the documentation. I can't seem to get it to return anything for me.

In my Mac app Xcode project I added an executable to a copy files phase and set that phase Destination to "Executables". This seemed like the logical place to do it.

This did not get a url when calling Bundle.main.url(forAuxiliaryExecutable)

I want to pass this url to Process.executableURL

I am able to generate the apropriate URL by calling Bundle.main.bundleURL then .appendPathComponent("Contents/MacOS/excutable") but am just curious about this forAuxiliaryExecutable

Am I misunderstanding what this would be for?


Replies

Am I misunderstanding what this would be for?

No. It sounds like you’re on the right track here.

I use url(forAuxiliaryExecutable:) regularly in my code and it Just Works™. I’m not sure why it’s failing for you. Please do the following:
  • Open a Terminal window, navigate to the directory containing your app, and run find against your app. Cut out all the extraneous stuff (everything except the entries related to Contents/MacOS) and paste it into a response here.

  • Also paste in a snippet showing exactly how you’re calling it.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"
Well... this morning it is working. I can not think of what is different other than a good night sleep. 🤷‍♂️
Thanks for the quick help!

@eskimo Here is what you asked for:
Code Block
Smart Desk.app/Contents/MacOS
Smart Desk.app/Contents/MacOS/Smart Desk
Smart Desk.app/Contents/MacOS/ffplay


What wasn't working yesterday but is now:
Code Block Swift
guard let ffplay = Bundle.main.url(forAuxiliaryExecutable: "ffplay") else{ fatalError() }


Yesterday's work around"
Code Block Swift
var ffplay = Bundle.main.bundleURL
ffplay.appendPathComponent("Contents/MacOS/ffplay")