inhwrbp
inhwrbp

Reputation: 619

App Sandbox capability missing in Xcode project

According to this guide, there should be an App Sandbox capability in the project file:

enter image description here

However, for some reason my app project does not have any App Sandbox capability that I can turn on:

enter image description here

Why is it missing, and how can I get it there?

Upvotes: 16

Views: 21536

Answers (3)

Andrew Kingdom
Andrew Kingdom

Reputation: 403

Add missing App Sandbox capability in Xcode

(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.

Upvotes: 8

Rahul Kumar
Rahul Kumar

Reputation: 77

If your Apple provisioning profile is missing the App Sandbox entitlement then it won't show up in xcode.

FYI - you can add manually to entitlement file, however it wont let you build unless described in your provisioning profile. Same goes for ditribution as well.

To Add entitlement > Open *.entitlements file as source code > add the following code.

<key>App Sandbox</key> <true/>

You can regenerate the provisioning profile with the desired capabilities, if you are the admin/team agent of the Apple store project.

hope this helps.

Upvotes: 6

Jeff Yang
Jeff Yang

Reputation: 251

First of all, you should open the ***.entitlements file. In this file, add a Key named App Sandbox and changed Value to YES.

After completing the above steps, click command + b then go back to Signing & Capabilities, the App Sandbox will appear.

Upvotes: 25

Related Questions