Skip to content

Instantly share code, notes, and snippets.

Last active June 21, 2023 14:27
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Simple Utility Script for allowing debug of hardened macOS apps.
#! /bin/bash
# Copied from
# Adding the else part to sign binaries giving the error:
## Cannot parse a NULL or zero-length data
## Error Reading File: /tmp/debug_entitlements.plist
if [ -z "$app_path" ];
echo "You need to specify app to re-codesign!"
exit 0
xattr -rc "$app_path"
# This uses local codesign. so it'll be valid ONLY on the machine you've re-signed with.
echo "Grabbing entitlements from app..."
codesign -d --entitlements :- "$app_path" >> $entitlements_plist || { exit 1; }
echo "Patch entitlements (if missing)..."
/usr/libexec/PlistBuddy -c "Add bool true" $entitlements_plist
if [ $? -eq 0 ]; then
/usr/libexec/PlistBuddy -c "Add bool true" $entitlements_plist
/usr/libexec/PlistBuddy -c "Add bool true" $entitlements_plist
cat > $entitlements_plist << EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">
echo "Re-applying entitlements (if missing)..."
codesign --force --options runtime --sign - --entitlements $entitlements_plist "$app_path" || { echo "codesign failed!"; }
echo "Removing temporary plist..."
rm $entitlements_plist
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment