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.)
- If your project lacks a
.entitlementsfile, create a new one:
- Menu:
View>Navigators>Project - Select the root level (project icon) of your project
- Menu:
File>New>File... - Use the
Property Listtemplate - Name the file after your project. Example:
MYPROJECT.entitlements.
- Edit the file:
-
Select the file in the Project navigator sidebar.
-
Add a new row (via the
(+)symbol, just as you would for a.plistfile.)key:
App Sandboxtype:Booleanvalue:YESThis 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>
- 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 Settingstab -
Select
All(show all build settings), notBasic -
In the list, find
CODE_SIGN_ENTITLEMENTS -
Set its value to the location of the
.entitlementsfile. If you created it at the root level of the project, this is just the filename, otherwise the relative folder path.Example:
butterflies.entitlementsExample: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