Skip to content

Instantly share code, notes, and snippets.

@akingdom
Last active August 16, 2023 20:31
Show Gist options
  • Save akingdom/91c4aa4bcb77d2fcade07909a4dcc58b to your computer and use it in GitHub Desktop.
Save akingdom/91c4aa4bcb77d2fcade07909a4dcc58b to your computer and use it in GitHub Desktop.

Add the App Sandbox capability to an Xcode project when it is missing from the standard capabilities area.

(Straightforward to do but a pain to remember.)

  1. If your project lacks a .entitlements file, create a new one:
  • Menu: View > Navigators > Project
  • Select the root level (project icon) of your project
  • Menu: File > New > File...
  • Use the Property List template
  • Name the file after your project. Example: MYPROJECT.entitlements.
  1. Edit the file:
  • Select the file in the Project navigator sidebar.

  • Add a new row (via the (+) symbol, just as you would for a .plist file.)

    key: App Sandbox type: Boolean value: YES

    This is the same as editing the source code (file contents) to be:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
    	<key>com.apple.security.app-sandbox</key>
    	<true/>
    </dict>
    </plist>
    
  1. Register this new file in the built target settings for your project.
  • Menu: View > Navigators > Project

  • Select the root level (project icon) of your project

  • In the project and targets list (left sidebar within the editor), select the target under TARGETS (not the Project)

  • In the editor area, select the Build Settings tab

  • Select All (show all build settings), not Basic

  • In the list, find CODE_SIGN_ENTITLEMENTS

  • Set its value to the location of the .entitlements file. If you created it at the root level of the project, this is just the filename, otherwise the relative folder path.

    Example: butterflies.entitlements Example: butterflies/butterflies.entitlements

I recommend then doing a Clean Build Folder, select a suitable build platform and doing a Product Build or Run.

Caveat: App Sandbox can be missing for other reasons but this is the most common one I come across.

Author: Andrew Kingdom

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment