How to add entitlements to a Xojo app using codesign

The answer is simple but complicated. I’m changing the title of this thread to be more generic.

<key>NSPhotoLibraryUsageDescription</key>
	<string>MyApp can use images, movies, and metadata such as title and description when you drag &amp; drop items from the Photos app.</string>
  • However, the actual key/value pairs for Entitlements instead have to be added during the code-signing process, they do not belong in Info.plist at all
  • To do this, first Create an entitlements plist file (the name doesn’t matter, but I use myapp_entitlements.plist) which looks like this:
<?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>
[... followed by a list of entitlements that you need for your app ... ]
	<key>com.apple.security.assets.pictures.read-write</key>
	<true/>
	<key>com.apple.security.automation.apple-events</key>
	<true/>
	<key>com.apple.security.personal-information.photos-library</key>
	<true/>
[... etc ...]
</dict>
</plist>
codesign --force --options runtime --deep --entitlements /path/to/myapp_entitlements.plist --sign  'Developer ID Application: my company' /path/to/myapp.app
  • to see what entitlements an app has, use this command:
codesign -d --entitlements :- /path/to/myapp.app