Valentin Shergin
Valentin Shergin

Reputation: 7334

How to determine if is sandboxing enabled or not

How to check if sandboxing is enabled or not at OSX app runtime?

I need it for some assert tests for my library that can be run in different environments.

Upvotes: 7

Views: 3951

Answers (2)

Valentin Shergin
Valentin Shergin

Reputation: 7334

Finally I have chosen this workaround (because it is simple):

func isSandboxingEnabled() -> Bool {
    let environment = NSProcessInfo.processInfo().environment
    return environment["APP_SANDBOX_CONTAINER_ID"] != nil
}

Upvotes: 9

Gianlucca
Gianlucca

Reputation: 1354

This might help

  1. In Finder, look at the contents of the ~/Library/Containers/ folder.

    If the Quick Start app is sandboxed, there is now a container folder named after your app. The name includes the company identifier for the project, so the complete folder name would be, for example, com.yourcompany.AppSandboxQuickStart.

    The system creates an app’s container folder, for a given user, the first time the user runs the app.

  2. In Activity Monitor, check that the system recognizes the app as sandboxed.

    • Launch Activity Monitor (available in /Applications/Utilities).

    • In Activity Monitor, choose View > Columns. Ensure that the Sandbox menu item is checked.

    • In the Sandbox column, confirm that the value for the Quick Start app is Yes.

    To make it easier to locate the app in Activity monitor, enter the name of the Quick Start app in the Filter field.

  3. Check that the app binary is sandboxed.

codesign -dvvv --entitlements :- executable_path

Upvotes: 5

Related Questions