Clicky

iOS Dev Nugget 118 Vendoring Code and Git Submodules

.

Need to run a code review on your codebase? Hire me

There are lots of wonderful open source code living on GitHub (and elsewhere) that you can plug into your projects. If you are using them but aren't vendoring those code in your project with Git submodules (or similar functionality), you should.

Put simply, vendoring is saving those 3rd party code into your source repository under a specific directory (often vendor/). This helps so dependencies on a specific version of a 3rd party library are tracked correctly with your project's source code.

When you vendor, if you use Git, you should always use git submodules instead of just copying and pasting the 3rd party code into vendor/libraryA/. i.e. do:

cd projectName/
git submodule add https://github.com/square/objc-TimesSquare.git vendor/objc-TimesSquare

and not:

git clone https://github.com/square/objc-TimesSquare.git
cp -R objc-TimesSquare projectName/vendor/

If you aren't using Git, other source code version control system should have similar functionality. This way, the history of the 3rd party code is preserved, and you can easily update to a newer version of the library and update that dependency in your project.

Of course, vendoring applies to internal shared libraries that you or your team develop too.


Your feedback is valuable: Do you want more nuggets like this?   Yes   or   No

.

.

Like this and want such iOS dev nuggets to be emailed to you, weekly?

Sign Me Up! or follow @iosdevnuggets on Twitter

.

View archives of past issues