Autogenerated acknowledgements in iOS settings bundle¶
Based on an article on howto create iOS settings bundles and a stackoverflow solution that takes .license files to display acknowledgements as child panel, I managed to integrate a project‘s acknowledgement list nicley.
Inspired by said stackoverflow solutions (Perl/python2) I created little python script and integrated it to my XCode setup as build phase. The script will create a acknowledement.plist file inside the settings.bundle folder. That file can then be displayed as child pane node.
import os
import sys
import plistlib
from pathlib import Path
os.chdir(sys.path[0])
plist = {‘PreferenceSpecifiers’: [], ‘StringsTable’: 'Acknowledgements’}
for filename in os.listdir(“.”):
if filename.endswith(“.license”):
current_file = open(filename, 'r’)
title = filename.split(“.license”)[0]
file_content = current_file.read().strip()
group = {'Type’: 'PSGroupSpecifier’, 'Title’: title, 'FooterText’: file_content} #noqa
plist['PreferenceSpecifiers’].append(group)
filepath = Path(’../Settings.bundle/Acknowledgements.plist’)
filepath.unlink()
with open(filepath.absolute(), “wb”) as outfile:
plistlib.dump(plist, outfile)
The snippet can be registered as Xcode build phase as explained on stackoverflow:
Go to your project file
Select the target
Click the Build Phases tab
In the lower right corner of that pane, click on 'Add Build Phase'
Select 'Add Run Script'
Modify to look something like this:
cd $SRCROOT/Licenses
python3 concatLicenses.py