Remote SVN has been working great for me as a combination of version control and backup.
Here is how I set it up. But I like the Git architecture of multiple distributed archives better, so I decided to switch.
I wanted a really simple setup:
- A project archive locally for each project.
- A remote archive for each project that I could push changes to periodically.
For the remote archive I wanted to use my Linux server running Centos. It's in my office connected by a fast cable system (>5 mbps upload) to the Internet.
Setting this up should have been simple, but it wasn't. XCode behaved strangely and frequently crashed. I got strange error messages; for example when I successfully connected to an empty remote repository, push wouldn't work, claiming that there were changes in the remote that needed to be pulled first. I finally succeeded.
Here are the steps I followed to finally get things working. I got some of the ideas from here.
- First of all, do all command line work with XCode closed. You shouldn't have to, but everything seemed to work better and some errors only went away when I started doing this.
- Set up your .gitignore. It is a file named ".gitignore" that you put in the root of your project, and it tells git which files not to track. You must do this before running any git commands. Here's mine, copied in part from several sources, with additions. Most of the entries are things in the XCode project that reflect UI state and can change rapidly, making it impossible to achieve a cleanly checked-in archive.
- Follow the process documented in the XCode Organizer Documentation tab to initialize a local project:
- At this point you can start XCode and check that it finds your local repository, and allows you to commit updates. Quit XCode again for the next step.
- Create a bare copy of your local repository to upload to the server. Note the --bare option on the git clone command.
- Upload the compressed tar (the .tgz) to your server, and login to the server.
- On the server, uncompress the tgz in the directory where your remote will live. I created a user named git and placed mine under /home/git.
tar xvfz test.tgz
- Start XCode and add the remote. Three key points:
- The remote is added under the "Remotes" folder of your local archive, not as a new archive. This is very confusing at first, as you can't find anything in the interface to tell you where or how to configure a remote until you click the magic icon.
- The remote needs to be specified with its complete path, e.g.
ssh+git://git@myserver.com/home/git/test.git
- XCode is very picky about remote names. It will let you enter the name and the complete URL, only to reject the name and erase your URL, forcing you to start from scratch. The one rule I have detected is no spaces; there may be others.
- You should now be done. Try doing a push to see if it works.
$ cat .gitignore xcuserdata *.xcuserstate build/ *.pbxuser *.perspective *.perspectivev3 *.old
git init git add . git commit -m "initial commit"
cd .. git clone --bare test Cloning into bare repository test.git... done. tar cfvz test.tgz test.git
The configuration needed on my Centos server was minimal. I'm assuming this is all working through Apache WebDAV, but I am surprised and pleased not to have found myself in a permission-setting, daemon-configuring fire drill.
Overal, this procedure seems needlessly long and complex. It should be possible to create this simple configuration using only git and XCode. But it works well now. If anyone knows a better way I'd love to hear it.