I'm looking for a way to launch the PTY process outside the sandbox. I
was hoping there was some API to gain such a permission (maybe by
asking the user for consent), but such a thing does not seem to exist.
Yes, but also no (-: More on this below.
Any process spawned by my sandboxed app will also be sandboxed and
inherits the restrictions.
This depends on what you mean by “spawned”. A sandboxed app can start processes in two ways:
-
As a child process, using fork/exec, posix_spawn, NSTask, and so on
-
As an independent app, using Launch Services, NSWorkspace, and so on
A child process always inherits its sandbox from its parent. An independent app does not. If the app is sandboxed, it starts in a new sandbox set up based on its App Sandbox entitlements. If not, it starts without a sandbox.
The sticking point for you is that App Review requires that all code within your app be sandboxed. So you can’t include a non-sandboxed helper app within your app, nor can you ask the user’s permission to start some app without its sandbox.
In summary, your conclusion is correct (-:
The only way to spawn a process that is not sandboxed is by having the
user manually launch a separate, non-sandboxed app (let's say a
daemon-like app without UI that runs in the background and may start
automatically when the user logs in), that my sandboxed app could then
talk to …
Do you agree?
Not really. The approach you’ve described should work, but I’m not sure it’s the only way to achieve your user-level goal.
Before we go any further, however, I want to clarify some terminology. On macOS a daemon is a privileged component that runs system wide. This is definitely inappropriate for your user case. What you’re describing is an agent (like a daemon but run once per login session), a background-only app (an app-like executable that shows no UI), or a UI element (an app-like executable that shows limit UI, for example, a system-wide status menu).
Coming back to your main issue, I have a further question about your user-level goals. You wrote:
The goal is to spawn an interactive terminal process (PTY) that
behaves just like the regular Terminal
If that’s the case then why not use Terminal itself. What’s the ‘value add’ of you doing all this work within your app?
My thinking here is that, rather than extending your app to provide a terminal UI, you could extend Terminal to provide access to your IDE’s features. That’s a lot easier because Terminal is not sandboxed.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"