How to contribute code to an iOS open source project

by @ralfebert · published June 30, 2021

As software developers we're often standing on the shoulders of many other developers before us who made public little pieces of their expertise and results of their research work by writing blog articles or answers on Stack Overflow or by publishing open source components on GitHub.

If you made a change to an open source component that improves the component, it might be worth considering contributing it back using a pull request.

If you've never done that before, I suggest doing a practice run to lower the barrier for your first actual contribution to the large corpus of open source software that's available at our fingertips.

  1. Clone the project SwiftAlgorithmsExamples which contains some examples for the Swift Algorithms package.

  2. Run the project and make yourself familiar with the Views:

  3. Have a look at the list of algorithms available in Swift Algorithms and find one algorithm that piques your interest and for which no example exists currently.

  4. Duplicate one of the existing Views and modify it to provide an example for this algorithm.

  5. Create a branch in your local repo for the change using your favorite Git client and commit the change you did.

  6. On GitHub check the license of the project - it's generally a good idea to check the license before using / contributing to an open source project. This project uses the MIT license which is one of the most permissive licenses available.
    Then use the fork button to create your own fork of the repository (you need a GitHub account for this):

  7. Now you can only push in your own repo, but not in the one you originally cloned. So you need to change the URL of the origin remote for your local repository (or add another remote for your own fork). So find out how to do this in your favorite git client. I recommend Fork, there you can change the URL of the origin like this:

  8. Push your local branch to the remote repository.

  9. On GitHub, create a Pull Request for your change:

Congratulations! You earned the badge "contributed to an open source project" :)