How to use Xcode with a cloned git repository - xcode

I am new to gitHub and have been invited to work on a private project. I am familiar with XCode and would like to use it to work on the project for it's autocompletion capabilities that I am used to. My problem is I don't know how to set this up so that I can pull the git repository, edit and test in XCode and then push. I have gone through a few tutorials on setting up git in XCode and I am successful in being able to connect to a repository I have pulled, but don't know how to use this as an XCode project once I have done so.
Here are a few specifics:
I made an SSH key for my computer and have cloned the repository through the terminal. Obviously I can update the files here and then use git commit and git push, however I want to use XCode for editing for code completion.
This project has a make file, though I don't know how to use these other than just typing "make all" in the terminal. I am assuming that I can set this up with Xcode so that when I build it uses the make file, but reading the documentation on this made me realize I don't understand enough to set this up.
I have tried making an Xcode project and then importing my files, but the problem is that Xcode insists on making a directory inside the project folder with the same name as the project where it stores all of the files. Therefore all of the addresses for my header files become wrong.
I assume that cloning a git project and then editing in Xcode is pretty standard. Does anyone have a place I can go for help?

Download SourceTree from the app store. It's free and kicks ass. You can just clone it in the terminal window using 'git clone WhateverOneYouWant -b WhicheverBranch'. Then just drag the project from the finder into the main sourceTree window.
Or alternatively, you can just grab it directly from gitHub on the main opening page of xcode. If there are no projects currently open, in the left part of the opening window, you'll see a line that says 'connect to a repository'.
Let me know if you have questions!

This isn't an exact answer to your question, but it does work.
If you install git separately and clone from the command line, you can:
Use Spotlight to Locate the Project folder you cloned
Double click the corresponding .xcodeproj file and start editing.

Related

Open old version of Xcode project files stored in GitLab

I am trying to figure out how to open an old version of my Xcode project that is stored in GitLab. Usually, I use Xcode to push updates to Gitlab and on the occasions, I've had to get my project from GitLab, I simply click the "Open in Xcode" button on GitLab, which brings my project up.
The problem that I'm having now is that I've accidentally introduced a bug into the project that crashes the app and I can't figure out how to crush this bug. The last couple of updates to GitLab contain this bug so I need to revert to a copy a bit in the past. When I click on this update, there is no open in Xcode button, and I'm unsure about how to open this previous version.
I'm hoping that there is a straightforward solution to getting this old version of this file up. I'm just getting started using git, and I'm hoping someone on here can provide some insight.
Can someone please point me in the right direction on the easiest way to revert to an old project update on GitLab?
It seems easier to:
close XCode
cd /path/to/local/clone/of/GitLab/repo
switch to the command line and type git switch <old SHA1> in order to update the working tree with the files content of that past SHA1
open XCode back up.
(Note: git switch is better than the old legacy git checkout command)
If you want to commit some fixes, your git switch command will be:
git switch -c fix <old SHA1>
That will start a fix branch starting from <old SHA1>.

How to solve: Xcode shows files still as modified after commit

I am using SourceTree as a git client.
A while ago, I had a major problem with my project and my git, so I had to reactivate a copy of my workspace from an external source. For that purpose I had created a complete new repository. Commiting to that now.
Today I've noticed, that most of my files appear as "modified" in Xcode. Even after commit and push (with SourceTree).
Source Control shows my two branches, what is correct:
And the History shows perfectly all the commits:
My feeling tells me, that in the background the old repository information is still present and does this bug. How do I handle this? Help is very appreciated.
Edit:
git diff --ws-error-highlight=new,old Output
Close Xcode. If you can avoid it, don't reopen Xcode :-) If it's an absolute must, reopen Xcode. The M markers should be gone.
This worked for me:
Delete derived data folder(Steps: Click Xcode on top left -> Preferences -> Locations -> Click on the right arrow below Derived Data and that will you take you to the Derived Data folder in Finder. Delete it)
Quit Xcode (Don't just close the project)
Reopen Xcode
Check if the nature of the diff is related to eol (end of lines).
See "git diff - show me line ending changes?", like:
git diff --ws-error-highlight=new,old
If that is the case, try first:
git config --global core.autocrlf false
Then try again to clone your repo, and see if XCode still display those differences.
In your case, this is not about eol, but about an update done in your files.
Check for any .gitattributes file: is there a smudge directive in those files (which would explain an automatic process taking place on checkout)
See Keyword expansion for an example of smudge script.
Something seems to update JTAppleCalendar to its latest relase (6.0.1 from 7 days ago)
My feeling tells me, that in the background the old repository information is still present and does this bug.
Simply try, in command-line, to clone again that repo (in a brand new local path) and check if the issue persists in that new cloned repo.
to the JTAppleCalendar, I have changed from 6.0.0 to 6.0.1 manually. around 7 days ago. when the new xcode 8.0.1 arrived
In that case, all those files should be listed as modified: that is what Git does.

All files missing from Git, Frameworks gone from Project Navigator

I was attempting to add a remote repository to my already in progress project. In the process of doing so all my files disappeared from the Commit section of Source Control (Using Git)
Also, all of the Frameworks that I downloaded from the internet (specifically my Parse Frameworks) disappeared from Finder and appeared red in the navigator.
Any ideas on how to fix this? I attempted to "Discard all Changes..." which proved to do nothing, and I tried dragging in newly downloaded frameworks, which also did not work. Should I just make a new project folder?
Looks like your frameworks folder got nuked/moved.
Without more info, this is my generic advice: first make a copy of the directory which encapsulates your git repo. Then look into the git commands git reset and the big hammer git reflog. Good luck.

How to delete files or folders in a git repository using Xcode?

My project had several folders that accidentally got added to my GitHub repository. I could delete them (one file at a time) from the GitHub website but that is tedious for a large number of files. I tried using git on the command line but it was conflicting with the Xcode source control updates. I would just like to do it graphically in Xcode if possible.
The closest Xcode question that I could find was this one, but it was about removing source control altogether, which I don't want to do.
I struggled with this for quite some time but it turned out to be fairly easy. I am sharing my answer below.
As long as you have your project already connected to a remote GitHub repository, all you have to do is use Finder to delete the files or folders.
Then go to Source Control and choose Commit and after that Push.
This will delete the files from your GitHub repository without you having to use the command line.

Source Control on already existing project Xcode

I've read that developers really need source control. Now I never used it before and I'm a bit lost with my existing projects.
How do I setup it?
There's already a File path inside of it, but it goes to nothing? I don't even know what it does in there.. I want a local git for my own. I found how to set it up with Terminal. But I think there should be a right way on doing this with Xcode and not with Terminal?
I'm sorry to say that Xcode does not have an option to place an existing project under version control. You can however use GitHub for Mac which will allow you to do this. It also has convenient merging tools and lets you push your code to GitHub.com if you like, all at the touch of a button: https://mac.github.com
It's easy enough to create a git repo from the command line though: open Terminal and navigate to the root folder of your project. Then type the following:
git init
git add .
git commit -m "initial commit"
Note that this approach as well as GitHub for Mac will version control every file in your project - which is not what Xcode does when you start a new project with Git enabled. You may run into trouble because your user interface state changes once every second - which can make committing and merging difficult.
The following article discusses this in detail:
http://pinkstone.co.uk/how-to-place-an-exiting-xcode-project-under-version-control-with-git-and-ignore-files-you-dont-want-to-track/

Resources