Running external binaries from Swift Package (TTS engine): Operation not permitted from Xcode app

Hi everyone,
We’re developing a macOS SwiftUI app that uses a local Swift Package (CasSherpaCore) to invoke an external compiled binary (sherpa-onnx-offline-tts) for text-to-speech synthesis using system calls. The package works flawlessly when tested from terminal or via a lightweight test C program.

However, when we invoke it from a SwiftUI app (even with Full Disk Access granted to Xcode and Terminal), we consistently get the error:

sh: /Users/xxxxxxxxxxx/SherpaONNX/sherpa-onnx/build/bin/sherpa-onnx-offline-tts: Operation not permitted

We’ve tried:

  • Granting Full Disk Access to Xcode and Terminal.
  • Removing the quarantine flag with xattr -d com.apple.quarantine.
  • Setting executable permission via chmod +x.
  • Using both system() and Process in C and Swift contexts.
  • Testing within a Swift Package that’s integrated into the app as a local dependency.
  • Running the command manually from terminal (works perfectly).

It appears that macOS (or Xcode’s runtime sandbox) is restricting execution of binaries from certain locations or contexts when launched via system() inside the app.

Questions:

  1. Is there a specific entitlement or configuration that allows execution of local binaries from a SwiftUI macOS app?
  2. Is this related to System Integrity Protection (SIP) or a hardened runtime limitation?
  3. Are there best practices or alternative approaches to safely execute local TTS binaries from within a Swift app?

Any help would be deeply appreciated. This is a core feature in our project and we’re stuck at this point. Thank you so much in advance!

This is almost certainly the App Sandbox in play. App Sandbox is very specific to Apple platforms, indeed to macOS, and thus somewhat off topic for Swift Forums.

Are you planning to ship this app on the Mac App Store? If not, my advice is that you disable App Sandbox and move on with your day.

OTOH, if you do eventually plan to ship your app on the App Store then we should talk about your issue in more depth, and it’d be better to do that over on Apple Developer Forums. If you start a thread over there, put it in the App & System Services > Processes & Concurrency topic area and tag it with App Sandbox. That way I’ll be sure to see it go by.

Share and Enjoy

Quinn “The Eskimo!” @ DTS @ Apple

3 Likes