jamone
jamone

Reputation: 17419

Git repo for framework inside local git project in Xcode 4

I have an iOS project in Xcode 4, that is using Git. Now I want to add the MKStoreKit framework to my project. It is already under version control using Git and a public repo. I'd like to include it in my project, and allow my project's git version control to do version control of the currently pulled version of MKStoreKit, while maintaining the ability to clone any updated MKStoreKit code with standard git ease. I see that a git submodule or subtree is probably what I need, but it seems like a real PITA. Is there not a simpler way?

So far any external code I add to my project I clone to a temp directory, then copy the individual files into my project. This feels like a kludgy way to do things.

Upvotes: 0

Views: 583

Answers (1)

larsks
larsks

Reputation: 312650

Check out the submodules section of the Git book. They're not really all that bad.

If you have a git repository, and you want to add another repository as a subdirectory, you can do this:

git submodule add git://github.com/MugunthKumar/MKStoreKit.git mstorekit

Now you have a directory "mstorekit" inside your project that is actually the MStoreKit repository. If someone clones your repository, they'll start with an empty "mstorekit" directory. Running:

git submodule init
git submodule update

Will clone the MStoreKit repository. They'll end up with the HEAD of the MStoreKit repository at the same commit as the one checked in to your repository.

Updating MStoreKit would look like this:

cd mstorekit
git pull origin master
cd ..
git ci -m 'updated mstorekit to latest version'

There are some alternatives out there, including git-subtree, which I saw mentioned recently around here. I have no experience with it (whereas I've been reasonably happy working with submodules).

Upvotes: 1

Related Questions