best way to add license section to iOS settings bundle

Viewed 47306

My iOS application uses a number of third party components licensed under Apache 2.0 and similar licenses, which requires me to include various bits of text, this kind of thing:

* Redistributions in binary form must reproduce the above copyright
  notice, this list of conditions and the following disclaimer in the
  documentation and/or other materials provided with the distribution.

There seems to be a reasonable precedent for putting this information under a 'License' subentry in settings bundle (on the ipad facebook, pages, keynote, numbers and wikipanion all seem to do this).

I'm struggling a bit to actually achieve the same though; I seem to need to split the text up line by line and enter into xcode a line at a time (and xcode4 seems to have a crashing problem when editing the plists).

It seems like the kind of thing that there's almost certainly a somewhere script to do, or some simple way to do it that I've missed.

10 Answers

Ack Ack: Acknowledgement Plist Generator
A while back I've created a Python script that scans for license files and creates a nice Acknowledgements plist that you can use in your Settings.plist. It does a lot of the work for you.

https://github.com/Building42/AckAck

Features

  • Detects Carthage and CocoaPods folders
  • Detects existing plists for custom licenses
  • Cleans up the license texts by removing unnecessary new lines and line breaks
  • Provides many customization options (see --help for details)
  • Supports both Python v2 and v3

Install

wget https://raw.githubusercontent.com/Building42/AckAck/master/ackack.py
chmod +x ackack.py

Run

./ackack.py

Screenshot

Acknowledgements

If you have suggestions for improvements, feel free to post an issue or pull request on GitHub!

Aknowlist is a strong CocoaPod candidate that is actively maintained at the time of this writing. It automates this licensing if you are okay with housing the licenses in your app rather than the settings bundle. It worked great for the project I was working on.

I had to modify sean's script for modern python3:

import os
import sys
import plistlib
from copy import deepcopy

os.chdir(sys.path[0])

plist = {'PreferenceSpecifiers': [], 'StringsTable': 'Acknowledgements'}
base_group = {'Type': 'PSGroupSpecifier', 'FooterText': '', 'Title': ''}

for filename in os.listdir("."):
    if filename.endswith(".license"):
        with open(filename, 'r') as current_file:
            group = deepcopy(base_group)
            title = filename.split(".license")[0]
            group['Title'] = title
            group['FooterText'] = current_file.read()
            plist['PreferenceSpecifiers'].append(group)

with open("Acknowledgements.plist", "wb") as f:
    plistlib.dump(plist, f)
Related