Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extracting entitlements from Xcode capabilities

I need to obtain an entitlement file generated by Xcode automatically when you're building a project.

Normally (even when you don't have any explicit capabilities selected), you can find one at $DERIVED_FILES_DIR/$PRODUCT_NAME.xcent, it contains generic information about your team and keychain access.

Does anyone know a way to generate it bypassing the build phase. I want to figure out a flow that is unrelated to the fact whether explicit entitlement file was specified or when Capabilities pane was used to specify them.

Perhaps I'm missing something obvious, any information would be greatly appreciated.

like image 339
Sash Zats Avatar asked Jun 29 '14 15:06

Sash Zats


People also ask

What are Xcode entitlements?

An app stores its entitlements as key-value pairs embedded in the code signature of its binary executable. You configure entitlements for your app by declaring capabilities for a target in Xcode. Xcode records capabilities that you add in a property list file with the . entitlements extension.

How do I set entitlements in Xcode?

Select iOS > Resource > Property List. Name the new file " foo. entitlements " (typically, " foo " is the target name) Click the (+) next to "Entitlements File" to add a top-level item (the property list editor will use the correct schema due to the file extension)


1 Answers

I actually found a way (thanks to Apple's engineers):

$ codesign -d --entitlements - /path/to/app/bundle.app:

<?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/>
    <key>com.apple.security.files.user-selected.read-only</key>
    <true/>
    <key>com.apple.security.network.client</key>
    <true/>
    <key>com.apple.security.network.server</key>
    <true/>
</dict>
</plist>

hope it helps you, too!

like image 187
Sash Zats Avatar answered Oct 04 '22 11:10

Sash Zats