Skip to content

Instantly share code, notes, and snippets.

@itsnebulalol
Created August 7, 2022 23:07
Show Gist options
  • Save itsnebulalol/adfaf60049b351e11fbe30db3890579b to your computer and use it in GitHub Desktop.
Save itsnebulalol/adfaf60049b351e11fbe30db3890579b to your computer and use it in GitHub Desktop.
Recursively sign frameworks with ldid.
import plistlib
from glob import glob
import os
import subprocess
frameworks_path = "/path/to/frameworks"
cert_path = ""
cert_password = "password"
for fpath in glob(frameworks_path + '/*.framework'):
fname = os.path.basename(fpath)
if Path(f"{fpath}/Info.plist").exists():
with open(f"{fpath}/Info.plist", 'rb') as f:
info = plistlib.load(f)
if info["CFBundleExecutable"]:
f_executable = info["CFBundleExecutable"]
else:
f_executable = None
if f_executable is not None:
print(f"Signing executable in {fname}")
f_exec_path = os.path.join(fpath, f_executable)
subprocess.run(['ldid', f'-K{cert_path}', f'-U{cert_password}', f'{f_exec_path}'], stdout=DEVNULL)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment