Easily add acknowledgments to your Xcode projects

May 2014

When you’re working on a iOS or OSX app, you’re bound to use a library, framework or other code that was generously shared by other people. The right thing to do (especially when the license requires it!) is to acknowledge that you’re using their work in your app.

There are various ways to go about this, but I’ve just released a script called Acknowledge that will make it very easy. It also works very well with DCOAboutWindow, which I released earlier.

![Acknowledgments] /assets/img/old/content/acknowledge-acknowledgments.jpg)

Acknowledge is a simple bash script that will easily generate a rtf that contains all the acknowledgments for libraries, frameworks and other code you’ve used in your iOS or OSX project.

It’s made to work very well with DCOAboutWindow and Cocoapods. Acknowledge relies on MultiMarkdown by Fletcher Penny.

You can read more about Acknowledge on GitHub, or follow the setup guide below.

Clone

Clone the repo, preferably into the root of your Xcode project:

$ git clone git@github.com:DangerCove/Acknowledge.git

Or if your project is a repo already, add it as a submodule:

$ git submodule add git@github.com:DangerCove/Acknowledge.git

Install multimarkdown

Follow the guide on Fletcher’s website, or if you’re using homebrew:

$ brew install multimarkdown

Configure

Copy acknowledge.cfg.default to acknowledge.cfg:

$ cd Acknowledge
$ cp acknowledge.cfg.default acknowledge.cfg

Customize the paths to multimarkdown and your Pods folder if necessary.

Add acknowledgments

If you use Cocoapods and have your Pods directory setup, you are ready to go. Just run acknowledge.

$ ./acknowledge

Other acknowledgments

Just add a markdown file to the sources directory and Acknowledge will handle the rest. Make sure the extension is .md.

Order

You might’ve notice the 10_ and 20_ prefixes in front of the files in the sources folder. Acknowledge will concatenate the files in order, so just add files and change to number to change the order.

The acknowledgments generated by Cocoapods will always be prepended with 10_.

Potential directory layout

.
|- Acknowledge/
|   |- acknowledge
|   |- ...
|   |- source/
|   |   |- 11_Vendor.md
|   |   |- 20_Acknowledge.md
|- Pods/
|   |- Pods-acknowledgements.markdown
|-  |- ...
|- Podfile
|- Coolproject.xcodeproj
|- Coolproject.xcworkspace
|- ...

Test it

Don’t skip this step, you’ll need to output in the next one.

Open a terminal window and run acknowledge once to see if it works, and to generate the initial Acknowledgments.rtf.

$ ./acknowledge

Fix any errors and proceed.

Add it to Xcode

You’ll probably want to show the acknowledgments somewhere in your app (have a look at DCOAboutWindow if you’re working on a Mac app, btw).

Simply add the generated Acknowledgments.rtf file to your project and display it somewhere.

Generate the acknowledgments on each build

Keeping your acknowledgments up to date is easy if you add Acknowledge as a build phase. Here’s how that works:

  1. Open Xcode;
  2. Select your project and open the Build Phases tab;
  3. Click Editor → Add Build Phase → Add Run Script Build Phase;
  4. Name your script something like “Update Acknowledgments” and position it so that it’s above Copy Bundle Resources;
  5. Now add the following code:

cd Acknowledge && ./acknowledge

(Make sure to adapt the paths if the script isn’t located in the default folder.)

It should look something like this:

Acknowledge build phase

That’s it! Just build your project and you’re set.