Monday, November 12, 2012

How to add an existing Xcode project to Source control

If you create a project in Xcode and later you want to add it to source control then you need to run a couple of command line controls. But it's easy.

1. Quit Xcode.

2. Open terminal and navigate to your directory. Using something like:
cd Developer/myprojectname
There is a file in Xcode that we do not want to add to source control. This records the Xcode environment state. Because we're doing this adding manually, we have to tell Git manually to ignore it. If we had told Xcode to add the project to source control when we created the project it would have ignored this file automatically.

3. Type the find command to find the file file.
find .
The file we are looking for is UserInterfaceState.xcuserstate

4. Place the file name into an exclude file.

echo myproject.xcodeproj/project.xcworkspace/xcuserdata/John.xcuserdatad/UserInterfaceState.xcuserstate >.gitignore

This will create the file gitignore

5. Initialise Git
git  init
Did you get an error? (See bottom of post)

6. Add the files
git add .

7. Commit the files to the repository

git commit -m "write a short comment here"

Problem with Git?
Are you getting the command not found?

bash: git: command not found
This can be solved by:

  1. Open Xcode
  2. Open Preferences
  3. Chose the Downloads tab, choose components
  4. Instal the Command line tools.
Bob's your uncle.

No comments:

Post a Comment