Git repo for framework inside local git project in Xcode 4 - xcode

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.

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).

Related

git clone --recurse-submodules fails silently

I have added a submodule to one of my repositories hosted on GitLab. In my browser GitLab displays the correct submodule#commit entry and the .gitmodules also looks okay. However, if I clone the repository using --recurse-submodules, the folder which should contain the submodule is empty.
I realize that this is impossible to diagnose without further information (which I cannot provide) but all I'd like to know here is how to go about debugging this myself since git fails to provide any information on what's gone wrong.
EDIT: I believe I've figured it out. I'm on Windows (which I forgot to tag, sorry about that) and my .gitmodules contained submodule paths using escaped backslashes (which I thought was correct), manually changing those to forward slashes fixed the problem.
You can try this after cloning you repository:
$ git submodule init
$ git submodule update --remote

Why doesn't Git track files modified in Xcode?

I'm using Git on the terminal to commit changes & push them to a remote repo.
Git can recognize when I create a file or modify a file via VS Code. However, when I work on my files on Xcode and save them, Git doesn't track any changes. It tells me:
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working tree clean
What's the problem and how can I fix it?

Xcode 7 / Git - Working with Workspaces

How do you work with Xcode workspaces in git? Until now, I've successfully added several projects to a workspace with each individual project having its own git. Each project then gets pushed to the remote server (github).
Works great, but the problem comes when checking out the entire workspace. I need to check out each project individually, making sure they have the same relative paths as they had on the original computer that made the push. Its tricky and prone to errors.
Is there another way?
Having faced the same problem myself, I used git submodules for the projects I wanted to add them to the main project.
Adding submodules:
$git submodule add https://github.com/chaconinc/DbConnector
$git submodule init
$git submodule update
you can update to changes on your remote server:
$git submodules update --remote
more info Here

Xcode Bots do not update git submodules to specified commit

My Xcode Bot is using an outdated version of my repo's submodules.
It builds old submodule code despite the submodule being updated to a new version in the commit history of the parent app.
Parent repo uses submodule v1.0.
Parent repo updates submodule to v2.0 and commits subproject commit to github.
The "on commit" Xcode Bot is run for the new commit automatically.
Parent app is uploaded to TestFlight.
TestFlight build contains the correct v2.0 submodule commit (the last commit to parent repo).
However the TestFlight build contains the outdated submodule v1.0 code.
I thought I was going crazy when my bugs were reproducible on the TestFlight build despite being "fixed" in the submodule and local builds.
It turns out Xcode Bots do not properly pull the specified submodule commit.
A simpler solution to this problem which doesn't require the server having credecentials for your git remotes - add this as a pre-integration script for your bot:
#!/bin/sh
# Enumerates each submodule to check out the desired commit.
# Needed because Xcode bots for some reason prefers to check out
# the branch head, which may result in the wrong commit.
cd "$XCS_PRIMARY_REPO_DIR"
git submodule foreach --recursive 'git checkout $sha1'
It recursively enumerates your submodules and checks out the commit expected by the parent repo.
As of Xcode 6, Xcode Bots are not guaranteed to update the repo's submodules to the specified commit.
You will need to manually update the submodules prior to the Xcode Bot's build:
git submodule update --init --recursive
To make this easier I've added updateGitSubmodules to the cavejohnson Xcode Bot scripting tool. Add the following to your Before Integration Run Script phase to update submodules automatically:
Before Integration > Run Script:
#!/bin/bash
PATH=/Library/Frameworks/Python.framework/Versions/3.4/bin:$PATH
cavejohnson updateGitSubmodules
Finally, we've opened an ticket to explore how this behavior can be fixed upstream.

Pull specific revision from master branch?

Im very new to Git and what I want to do with git within xcode is pull an older revision of my master (not commandline). Is this possible? I've looked in repositories under the organizer and i see all my commits there but i cant seem to load in one of them.
You can't go back to an earlier version of a repository from Xcode in Xcode 4. Older versions of Xcode allow you to go back to an earlier version of a repository, but older versions of Xcode lack git support.
I think that if you have cloned/pushed your repo all the stuff you need is on your local drive.
If you want to see how code looks in specific commit, do
git checkout branch_name
or
git checkout 14646bf1a76d08cbda99317c4faa8de0072d6975
where branch_name can be alias for checksum used by git, (like master or origin/master), if you want to list your branch checksums you can do that by
git log
or if you want it in GUI use qgit gitg or my favourite tig, or whatever you'll find to list your commits

Resources