Skip to content

Instantly share code, notes, and snippets.

@wagyu298
Created October 23, 2016 06:22
Show Gist options
  • Save wagyu298/cb11f5d6eabd9acc7425cc106fc03fd2 to your computer and use it in GitHub Desktop.
Save wagyu298/cb11f5d6eabd9acc7425cc106fc03fd2 to your computer and use it in GitHub Desktop.
Merge iOS Acknowledgements.plist files with CocoaPods
#!/usr/bin/env python
# Merge extra iOS App's Acknowledgements.plist into CocoaPods generated
# Acknowledgements.plist.
# Run "pip install dpath", s/MyApp/YourAppName/g, and replace extra_plist
# before use this script.
from __future__ import print_function
import operator
import plistlib
import sys
import dpath
pod_plist = "Pods/Target Support Files/Pods-MyAPP/Pods-MyAPP-acknowledgements.plist"
extra_plist = ["MyAPP/modules-acknowledgements.plist"]
data = plistlib.readPlist(open(pod_plist))
first = data['PreferenceSpecifiers'].pop(0)
last = data['PreferenceSpecifiers'].pop()
for f in extra_plist:
dpath.util.merge(data, plistlib.readPlist(open(f)))
data['PreferenceSpecifiers'].sort(key=operator.itemgetter('Title'))
data['PreferenceSpecifiers'].insert(0, first)
data['PreferenceSpecifiers'].append(last)
plistlib.writePlist(data, sys.stdout)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment