Configuring Xcode to use Subversion
Whether you are a new Apple developer or an experienced Cocoa
engineer with roots in NeXTStep,
you will understand the need to back up your hard work. Integrating Xcode with subversion not only allows you to back up your code, but it also enables you to keep a history of changes that you can revert back to or compare your code against. This is called version control. This article assumes that you already have your own subversion repository that you have read and write access to. If you want to setup a subversion server of your own, I suggest consulting the almighty google for a wide range of articles on how to accomplish this task. Read on for screenshots, details and lots of fun.
Step 1) Tell Xcode about your repository.
Xcode has the ability to communicate with subversion using native svn communication, ssh+svn, http and https. The most popular of the various methods is https which allows you to save your data over an encrypted channel. Because after all, it is important that your trade secrets are never exposed to your competitor! To add a subversion repository, navigate to the “SCM” menu and select the “Configure SCM Repositories…” option. Fill in the relevant information which should be readily available to you, if it’s not, contact the person who administrates your SVN repository for more details.
Step 2) Let’s put your code on the Subversion server
Go back to the SCM menu and select the “Repositories” menu item. From this screen you can now “import” your hard work into the repository. Click the “Import” button and navigate to your Xcode project’s directory. If you haven’t done so already, you might want to think about configuring your project to use a directory for builds that lives OUTSIDE of your Xcode project directory. If you configure your build paths (in your Project Settings) in this manner you will avoid checking in binary copies of your application, which is typically unnecessary as subversion is source control management (SCM) not binary control management. After you have settled on your build path situation, go ahead and select your entire Xcode project and import it. If the subversion server is “local” to your computer this process will be lighting fast. If not, wait a while for it to finish.
Step 3) Check-out your newly imported code from the repository
Now that you have stored your source code on the subversion server, the current local copy of your Xcode project can be moved off to the side, or even better, deleted. Don’t worry since you placed the files inside of the repository, we can quickly check them out so that your working copy will be attached to the repository. Navigate back to the SCM menu (noticing a trend here?) and select “Repositories”. From the repository browsing window select your Xcode project and click the “Checkout” button. Xcode will ask you for a place to save the project. Any location will do, just save it.
Step 4) Inform your Project that it is under SCM control
Time to tell Xcode that your project is being managed by SCM, or more specifically subversion. Pull your Project Settings and click the “Project Roots & SCM” button. It will bring up the window you see below where you want to select and then click the small black arrows until it reads your subversion repository. That it. Hit Ok and return to Xcode. Your project is now Subversion aware.
The Final Steps
The hard work has paid off. You can now right click the menu bar of the navigation sidebar and check the “SCM” entry. This will place an additional column in the sidebar which will have an “M” in it if a file is “newer” (meaning it needs to be committed) than what is in the Subversion repository. You can now right click a file and commit it to the repository. When you do that, Xcode will ask you to enter a comment that describes what changes were made to the file.
you will understand the need to back up your hard work. Integrating Xcode with subversion not only allows you to back up your code, but it also enables you to keep a history of changes that you can revert back to or compare your code against. This is called version control. This article assumes that you already have your own subversion repository that you have read and write access to. If you want to setup a subversion server of your own, I suggest consulting the almighty google for a wide range of articles on how to accomplish this task. Read on for screenshots, details and lots of fun.
Step 1) Tell Xcode about your repository.
Xcode has the ability to communicate with subversion using native svn communication, ssh+svn, http and https. The most popular of the various methods is https which allows you to save your data over an encrypted channel. Because after all, it is important that your trade secrets are never exposed to your competitor! To add a subversion repository, navigate to the “SCM” menu and select the “Configure SCM Repositories…” option. Fill in the relevant information which should be readily available to you, if it’s not, contact the person who administrates your SVN repository for more details.
Step 2) Let’s put your code on the Subversion server
Go back to the SCM menu and select the “Repositories” menu item. From this screen you can now “import” your hard work into the repository. Click the “Import” button and navigate to your Xcode project’s directory. If you haven’t done so already, you might want to think about configuring your project to use a directory for builds that lives OUTSIDE of your Xcode project directory. If you configure your build paths (in your Project Settings) in this manner you will avoid checking in binary copies of your application, which is typically unnecessary as subversion is source control management (SCM) not binary control management. After you have settled on your build path situation, go ahead and select your entire Xcode project and import it. If the subversion server is “local” to your computer this process will be lighting fast. If not, wait a while for it to finish.
Step 3) Check-out your newly imported code from the repository
Now that you have stored your source code on the subversion server, the current local copy of your Xcode project can be moved off to the side, or even better, deleted. Don’t worry since you placed the files inside of the repository, we can quickly check them out so that your working copy will be attached to the repository. Navigate back to the SCM menu (noticing a trend here?) and select “Repositories”. From the repository browsing window select your Xcode project and click the “Checkout” button. Xcode will ask you for a place to save the project. Any location will do, just save it.
Step 4) Inform your Project that it is under SCM control
Time to tell Xcode that your project is being managed by SCM, or more specifically subversion. Pull your Project Settings and click the “Project Roots & SCM” button. It will bring up the window you see below where you want to select and then click the small black arrows until it reads your subversion repository. That it. Hit Ok and return to Xcode. Your project is now Subversion aware.
The Final Steps
The hard work has paid off. You can now right click the menu bar of the navigation sidebar and check the “SCM” entry. This will place an additional column in the sidebar which will have an “M” in it if a file is “newer” (meaning it needs to be committed) than what is in the Subversion repository. You can now right click a file and commit it to the repository. When you do that, Xcode will ask you to enter a comment that describes what changes were made to the file.
Comments
Post a Comment