I haven’t looked into the Swift runtime side of this in detail, but I do want to address this specific point:
My command line tool resides in the MacOS directory …
You’re doing the right thing here. The
Contents/MacOS/ directory is the recommended place for embedded command-line tools, as witnessed by the fact that this is where
url(forAuxiliaryExecutable:) looks. Placing such tools in
Contents/Resources/ will eventually cause you code signing grief, as explained in the Nested Code section of Technote 2206 macOS Code Signing In Depth.
Share and Enjoy
Quinn “The Eskimo!” @ DTS @ Apple