When you copy and paste code, there’s no reference back to the original spot where the code was found, and it’s easily forgotten about. There are several problems with this approach though: Probably the most basic form of dependency management is to simply copy and paste code into your own app. It’s the practice of using configuration mechanisms to add extra code, and therefore extra features, to your software. What Is Dependency Management?ĭependency management is a concept that spans all software development disciplines, not just iOS development. Throughout the rest of this tutorial, you’ll add behavior to the app while integrating other dependencies with Git Submodules.įirst - a little bit of background on dependency management. You can try to select a photo, but the app won’t do much in response. Build and run, and you should see the following: Getting Startedĭownload the starter project for this tutorial. This will include both a private dependency for something like shared code between your own code bases, as well as a separate example where you pull in an outside third party dependency as a Git Submodule. In this iOS dependency management tutorial, you’ll learn how to use Git Submodules to manage dependencies for your iOS application. Whether you want to integrate someone else’s open source project, add a library from a third party service, or even reuse code across your own projects, dependency management helps you manage these complex code relationships - and guard against some messy problems. The next time you (or someone else) clones this repo, they will need to do one of two things.As an iOS developer, dependency management is something you’ll eventually encounter in your coding adventures. Commiting these changes will persist the new submodule tracking your desired branch. Now from your primary repository you still have two modified objects. Just easily I could set it to specific commit or tag. Now the submodule is fixed on the development branch instead of HEAD of master. Git checkout -b dev_branch origin/dev_branch In order to change the submodule to track a particular commit or different branch change directory to the submodule folder and switch branches just like you would in a normal repo. ** Step 2 : Fix the submodule to a particular commitīy default the new submodule will be tracking HEAD of the master branch but will NOT be updated as you update your primary repo. ** Fraser Speirs has a good writeup on what is going on behind the scenes with the Git internals and how the key to all of this is in the index files of each repo and the modes the changes are committed with. gitmodules will contain the submodule’s local path and source URL and a new folder named qunit which contains a full clone of your source repository. Git submodule add git:///asynchrony/qunit.git qunitĪfterward there will be two modified and staged objects in your repo. First grab the GitHub url for my QUnit fork (eventually this will be replaced with the main QUnit repo) and execute the “add” command from within your local repository root. Once the module is checked out, I need to add the QUnit submodule. In addition, I need my Git submodule to point to a specific commit (or branch) so that everyone cloning my code consistently can run my examples w/o fear that a new commit on HEAD will break something. The man page for git-submodule as well as the Git Book chapter on Submodules do a good job of documenting the command with some simple examples, but none that were 100% clear for my needs. A single submodule should allow me to keep QUnit-CLI inherently pointing to a particular revision of QUnit.js without requiring me to seperately document which version I was testing against. I have used SVN:externals prevsiously so Git submodules seemed like an obvious solution. While working on getting QUnit-CLI cleaned up and refactored a bit, I realized I needed to tie the example code in the Git repository to a particular version of QUnit.js (those guys are making changes too fast for me to keep up).
0 Comments
Leave a Reply. |