Xcode project templates Vol. 4: How to deal with third-party library licenses

Does it still take you a lot of time to create a new project? I've prepared another section dedicated to Xcode project templates that will save you time and a few hairs 😅. Read the how-to guide and maybe you'll change the way you create your projects. Today I'll show you how to integrate a screen with all third-party libraries into your project using the LicensePlist library.

Andrej Jaššo9 Nov 2021

Before we jump into the last part of the Xcode project templates series, don't forget to read the previous articles. In those, you'll find step-by-step tutorials 
on how to start and where to find templates, how to automate project configuration, or how to configure swiftlink and swiftgen.

LicensePlist is a tool that generates a plist of all third party books including SPM, Carthage and Cocoapod libraries.

At the end of this article, after creating the project and successfully running 
it on the simulator, we should see a license button in the application settings where we will see all used third-party libraries without any setup. Once you have successfully created a template, all future integrations are alredy done.

But let's give you little context first. Why mention libraries in the application 
at all? The reason is simple. If you've ever browsed the github of a library, you've probably noticed the LICENSE file.

Here are the terms of use of the library and even though the library is open source it is still quite possible that it requires a declaration of use in apps that are publicly available. Not every library requires it, but there is a good chance that you will sooner or later come across a library that will. It's actually a way not to cause legal problems.

Now let's go to integration. The first thing to do is add your LicensePlist 
to the poddependencies in our sub template.

The template for the team also makes sense because we make it easier 
to add more name search libraries, etc ...

As a next step, we will create a new sub-template where the only file will 
be settings.bundle and for the target we will determine, similarly to the previous article, the target where there will be 2 build scripts. These must refer 
to the Licene-plist script and the types will copy and paste to the settings.bundle file and then sequentially edit and delete the output.

You can create Settings.bundle simply via xcode and select the settings template.

You will create something like this where the content will be taken care 
of by a script that will copy all the information it retrieves from the libraries 
in the project. Copy the file created in this way and put it in the folder 
of our sub-template.

We will then add this template to our main project template.

Now just generate a project and see how the settings bundle fills your library information.

And at the same time, when installing the application on the simulator you can see that the licenses are here.

That's all for today's tutorial. At the same time, it should be added that you will find all the materials on the appropriate branch of our template repository.

Do you want to be part of an innovative team? Join us in iOS 🍎

Andrej Jaššo9 Nov 2021