Using subversion across visual studio and Xcode [duplicate] - ios

It seems that all of the initial Google results for "using subversion with xcode" are actually just tutorials for installing and configuring svn and Xcode, as opposed to actually using the two (i.e. interacting with svn via Xcode's GUI).
Is anyone aware of a good guide that teaches the tricks and pitfalls of working with svn via Xcode's GUI? Something that bridges the gap between the most excellent Version Control with Subversion book and the Xcode IDE (as in pure Xcode GUI without any terminal command use)?
Edit:
We all love our terminal commands, and we all love Eclipse but (and I mean this in the nicest possible way) neither is really the point of the question. I’d prefer to use svn via Xcode’s IDE instead of via terminal just as I prefer (well, for this case) to code in Xcode’s IDE instead of using vim and gcc. Apple engineers spent a good bit of time implementing that SCM menu in Xcode; someone has to have seen a usage guide somewhere.

I used this page as a reference for setting up my XCode projects with SVN. It is a good starting point, but I'll give a short walkthrough of what I did (since the page isn't really all that helpful!).
A couple notes: I'm using XCode 3.1.2 and Subversion 1.4.2. I've heard of problems with using SVN 1.5, but there are ways around that which I wont get into.
First off, I had a repository already set up and created the XCode project afterwards.
In XCode you need to set it up to know about your repository using the SCM tab in the preferences window. Enter:
A Name (this is arbitrary and used for reference with XCode)
The scheme (http or svn)
The host (i.e. svn.example.com)
The path (the exact path to the SVN repository located on the host)
The port (only if it isn't the default)
And a username and password used to access the repository.
The URL will be auto-filled as you enter the other fields. Hit "OK" when all the fields are good and XCode says it can connect.
Then open your project and do a "Get Info" (Round blue icon with an exclamation mark) on the project itself. Under the "General" tab down at the bottom is an option for SCM, select the repository you made in 1 and close the window.
Now open SCM in the menu-bar and go to "Repositories." Hopefully you've built your repository right using branches, trunk, and other directories at the base level because XCode doesn't have support for checking out the root directory. So go one directory at a time down the list and click the "Checkout" button and select a directory to check it out to (I recommend a "Code" or "Source" or "SVN" directory inside your XCode project directory). You cannot checkout multiple directories at once, but you can tell the next directory to checkout before the first has finished and XCode with queue the commands.
Once that is all done go back to your XCode project window and "Add -> Existing Files..." to your project. Select the directory you've checked out the repository to and I recommend using the "Create folder references" option instead of the "Recursively create groups" option because added and removed items will be automatically reflected in a Folder Reference but not in a Group.
Now you've imported your SVN repository into an XCode project. From here any time you make a change, simply Right-Click (Control-Click if you only have 1 button) in the file and at the bottom of the context menu are the SCM options for comparing, committing, updating, and discarding (reverting) the file. You can also use the SCM menu in the menubar for file or project-wide updates/commits/reverts.

I second the comment by the_mandrill, SVN support from within XCode is very limited, especially if you're used to Eclipse.
I also don't understand why everyone seems to need visual clients. I keep a terminal window open on my project directory and I have no problems interacting with SVN from the command line.

I know this is not quite what you asked, but I wouldn't rely much on the use of SVN from Xcode as what you can do with it is very limited. It's useful for being able to do a diff or annotate direct from the IDE but not a great deal else. I don't think it's any substitute for using a separate standalone client such as SmartSVN or Versions.
You also have to jump through a number of hoops to get Xcode to work with SVN version 1.5 onwards, so that's something to be aware of before installing a standalone client. If in doubt, check out a sandbox first.

Here is one of the best tutorials to configure subversion in XCode - http://iphonedevelopment.blogspot.com/2009/03/version-control-is-your-friend.html
It also teaches even to create repository in local MAC.

if you want to work with svn through a gui interface then i suggest you use eclipse + subclipse plugin (which have more features and much more reliable and easy than svn on xcode)..
you will work in xcode as normal but you will use eclipse only as an svn client (by creating a general project in eclipse and make it points to your xcode project directory )
and here is a tutorial of how to install subclipse

A lot of people have problems using the build in svn client, especially to get a new project into svn and that it works.
I created a straight foreward tutorial on how to do this, along with a very well known pitfall (works for Xcode up till the latest version of xcode incl. Iphone 4 sdk)
http://www.sodeso.nl/?p=599

I myself looked up for some good resources and one of the best I've found is a quite recent video from the WWDC 2012 :
Sign in here if it's not already the case : https://developer.apple.com/videos/wwdc/2012/
Then there is a video called :Session 411 - Source Control Management in Xcode
It explains how to use version control both with GIT and Subversion. It's really nice !
Hope it helps!

As has been mentioned in many other answers, the svn client with Xcode is quite weak (and that is being kind).
Personally, I think that running Eclipse just to get access to a svn client is a bit heavy handed.
I would suggest two answers:
Use a dedicated svn client for the Mac (Versions and Cornerstone are both very good, albeit not free... there are free ones, such as svnX)
If you are not wildly comfortable with the terminal, you can script a couple of the key commands that you want to use and add them to your Xcode user scripts folder, then you can trigger them from a menu item of from a keystroke, just as if you were using the Xcode native client. There's a ton of examples on how to do this available via Google.

I came across these - no idea how well they work, but wanted to add some resources if I could:
http://www.macresearch.org/tutorial-introducing-xcode-30-organizer
http://developer.apple.com/tools/subversionxcode.html

With XCode4 you can perform almost all of your SCM tasks from within the IDE itself, this is a great step forward.
Here is a link to the official guide :
http://developer.apple.com/library/mac/#documentation/ToolsLanguages/Conceptual/Xcode4UserGuide/SCM/SCM.html#//apple_ref/doc/uid/TP40010215-CH7-SW26
Unfortunately you still have to use the Terminal command line to add a new project to SCM, this is also clearly documented in the link above.
What it does not tell you is that you also need to manually add ignore instructions to your SCM configuration otherwise you are going to end up with user settings and build outputs in your repositories. I am currently figuring out the list and I will update this answer once I have it finalised.
PS :
I know this question is quite old now but I have added this for those of you who arrive here looking for answers like I did.
PPS :
Terminal command line increases probability of human error, takes longer, is more complex and is less transparent to end users. Overall the omission of being able to add projects to SCM from within XCode is poor design, I expected better from Apple who are usually good at simplifying UI. For the command line fans out there you might feel L337 but try managing a team of programmers and being responsible for their code, command line is not your friend.

Related

Xcode workspaces - how to properly save new versions/backup?

Im not sure this is the right place for this but I need an answer - in the past I have always saved backups (so I can revert back if I break something) of my Xcode projects by copy-pasting the project folder with the project tests/files inside (image below) and naming it a new version (i,e Project 1, project 2, so on):
This has worked well and in the past Ive been able to simply delete a screwed up version and open a past one and the code will be as I left it.
I have now started incorporating pods into my project so I am using the workspace instead of the Xcode project. This now brings in the issue of build "schemes" which appear in the upper left corner.
Not always, but sometimes after copy-pasting I will go back to a previous version and the code has "carried over" from the latest version/scheme. I don't really understand what a scheme is or if this is the problem but it has caused major problems at times.
When using the workspace, how does one properly save backups/new versions to go back to?
It sounds like you need a source control tool, the most used Source Control Management tool is called git. It's what a lot of people use, and you may have heard of GitHub - which is centered around git.
I'd recommend starting by going through this website: https://try.github.io/
As others have mentioned, you should definitely get acquainted with git. And the good news is that about a year after this question was asked, with the release of Xcode 9 (and with all subsequent versions since then), git is built right into Xcode. When you create a project, on the screen where you select the folder you would like to save the project to, you will see a check box, as in this screenshot:
Always enable this (i.e., check the box), and you will never again need to manually save versions of your project to separate folders, as you outlined.
Cheers!

On what change-set is my local working copy?

I want to be able to see (in VS2013 UI) till which change-set I updated my files.
The reason I ask this is because of the following scenario:
I created a fix, checked it in and continued working on something else. One day later, my colleague is testing the bug I solved but found it unsolved. Next, I tried to reproduce it at my machine but was not able to do so. So I wondered whether my colleague got the latest version before starting to test, he was convinced he did, but we cannot find a way to see on what change-set he is.
It is important for us to know this information without getting the latest version and retest it. Since the testing procedure for this bug takes quite some time, and time is valuable.
I'm quite new to TFS and we just switched from SVN to TFS. At SVN, using tortoise, the revision of the local working copy was highlighted, so the user knew which revisions he missed or was at.
I would like to be able to get this same information via VS2013.
I searched the web and found this other question but it uses the command line and I want to see it in the UI. Beside that, I couldn't get the command to work.
The question: Where can I find the number of the change-set in the VS2013 user-interface, my local working copy is on?
One place I know of is in the source control explorer window of Visual Studio.
1: right click a file and go to Advanced->Properties
2: Under the general tab you will see "Workspace Version #" and "Latest Version #"
In the Source Code Explorer you should have a column for "latest". This will tell you at a glance if you have the latest or not.

Checking in changes to TFVC from other solutions

I am using Visual Studio Online. I have projects which have common code that I use across a number of different solutions in different TFS projects and I also have some files which are linked from other TFS projects in some of them. In order to be able to access them all, I've changed the Workspace config so that I have just mapped $/ to a particular folder.
The problem is that I just checked in a change in one project and noticed that it also checked in a change in a completely unrelated one that wasn't part of the solution at all! How can I configure things to be able to access everything that I need to without cross-checking-in files from unrelated projects (and without having to manually exclude/include files in every check in)!?
EDIT: I've noticed that this doesn't seem to have happened again on my last couple of check ins when I also had items from other projects checked out. Wondering what caused it.
You should look at a NuGet solution for this. If you are using VSO you can use the new MyGet integration with an automated build process. If you create an automated build for the shared project output that is packaged in a NuGet package you can create a NuGet repository ion MyGet to provide it to your other solutions.
Once you have that, if you then change the shared code and check in, the build and package will kick off and deploy your new version of the package. Your other solutions will then prompt you to update automatically. You don't even need to check in the dependent assemblies as you can use NuGet Package Restore to make sure your local and build server get the right versions.
It sounds like a lot of work but once you get up to speed it only takes a few hours of investment to configure for anything you want to share or deploy in this way.
In the Pending Changes section of Team Explorer, in the Included Changes section there is a drop down. If it's set to "Show All" you'll see changes pending for all your solutions. If it's set to "Show Solution Changes" you'll just see changes pending for the current solution. (My guess is that it was set to "Show All" when you checked in your changes and that's why you got changes from other solutions checked in.)

Could not setup SVN in Xcode 5

I am not able to setup SVN in Xcode 5.
Iv tried these steps:
1) Goto-Xcode-Preferences-Accounts-Add Repositories (clicking "+" sign).
2) Enter the url to common server and click next.
3)Enter the credentials. At this point of time i get this error message
When i click ok i get this screen
Where do i go from here. No other Option left.
The source control seems to be like this.
Recommendation
I've answered a similar question here and provided references in my earlier answer. Generally speaking you should have been authenticated to the repository (if password is required) and then presented with a target directory. Please note that I am using Xcode 5.0.2 (5A3005).
You could also try importing a sample svn from an offline resource such as the one referenced in the image below. This would help you with validating that everything is correct on your machine/installation. At that point, I'd recommend extrapolating to see how your specific project might be different.
If all else fails you can go to Terminal and use the SVNBook resource from my other question to manually create a local SVN repository and then simply add that to your project. You could then work on adding a remote repo after you have the basics working.
My recommendation is use SVN via commands you can do this by download command online tools this is more reliable then GUI base tool.

Version control for graphics alongside iOS project

I'm working on my first iOS app and have decided to stop being irresponsible and do a good job with version control. My project has been migrated over to a new repository that I established with the DP of Xcode 5. There are a number of images that I've created with Paint Code and Pixelmator that most certainly deserve the same attention to version control as the source code for the app. I love having git hidden behind the UI of xcode - Is there a clean way to include other random files (like Pixelmator files for example) in the same repository as my iOS project and have it all maintained together? Presumably this would not happen in xcode. Don't want any files left out of the party.
I would recommend to use SourceTree or the command line for this. Every other git tool should work fine too.
You don't have to (and honestly, you should not) add your assets (.psd, .ai, .pxm, etc) to Xcode. Just commit them without Xcode.
I do exactly this since a couple of years. All my "raw" files go into an "assets" folder in the root folder of my project. Those files are not added to Xcode, I manage them with SourceTree.
Actually I manage the whole project with SourceTree. I don't use Xcodes Source Control features at all. The git support in Xcode is really basic if you compare it to SourceTree.
Once you've used "Stage Selected Lines" and "Stage Hunk" in SourceTree you can't go back to Xcode.
I put my graphic work files in a folder alongside Resources, but i exclude it and all its content from the target(s). Works for me (using Git).
Can't talk about Xcode 5 here since it's NDA - check out the developer forums for more info (once they get unborked from the hack attempt).
In every recent project I've worked on, we have just included the files in the git repository. Git handles binary files like images just fine, so Xcode should pickup the fact that they're modified and you'll be able to commit them. I personally use the command line 90% of the time, and the other 10% of the time I use SourceTree (for merging / conflict resolution).

Resources