2

Here is my setup -

Xcode 3.2.5 
Cornerstone 2.0
SVN server 1.6

I am using cornerstone for version control and nothing setting anything in xcode.

Now here is the scenario -

I am working in a team (We all decided to use SVN for our new project) of 5 programmers. Now when I add a new view controller (i.e. LoginViewController.m) on my system the .xcodeproj file gets changed immediately on my system.

Mean while another programmer also add one more view controller (SignupViewController.m). His .xcodeproj file also gets changed.

Now when I complete my code of LoginViewController I commit it. After some time the second programmer finish the SignupViewController and commits his work.

Now using the above procedure the .xcodeproj file gets corrupt and xcode won't open that project again.

Now my question is When should we commit our work when developing iPhone apps under xcode when using a third party svn client. Can someone please elaborate the process of when should we commit in cornerstone.

Should we commit the project just after when we add something in project (like files, images, music)?

It will be great if you can also provide me a tutorial on using xcode + cornerstone in real world.

Brian Webster
  • 27,545
  • 47
  • 143
  • 218
Saurabh
  • 22,325
  • 12
  • 80
  • 133
  • I take it the `.xcodeproj` file is a binary file? If not, you should be able to merge the changes / resolve conflicts when you perform updates from the repository. – forsvarir May 25 '11 at 11:23
  • @forsvarir: The `.xcodeproj` "file" is actually just a regular directory, containing half a dozen XML files. – Sedate Alien May 25 '11 at 11:37
  • @Sedate Alien: Then the problem is coming from @Saurabh not performing an update, prior to commiting (I've never worked anywhere that this wasn't frowned on)? Otherwise I'd have expected there to be local conflicts / updates that would never make it into the repository. – forsvarir May 25 '11 at 11:43

2 Answers2

4

One way to do this:

Whenever you want to change something to the project structure (add a class for example), you first update your working copy, make the change, and commit right away. Of course that means you'll check in an empty class, but that's no big issue in most cases. If everyone follows that rule, you shouldn't have any problems.

Philippe Leybaert
  • 155,903
  • 29
  • 200
  • 218
  • Exactly. If you update first, it'll try to overwrite and merge your existing xcodeproject file. If you commit, you'll commit a merged file. If it's unsuccesfull, SVN will let you know! – Joetjah May 25 '11 at 11:21
  • @Philippe Leybaert - but when I update my copy with latest revision the .xcodeproj (or specifically I should say - project.pbxproj in .xcodeproj folder) my own changes will be lost.. won't they? – Saurabh May 25 '11 at 12:12
  • No, because you should always commit right away after you made changes to the project file. So the order is: update - make changes - commit – Philippe Leybaert May 25 '11 at 12:14
  • But I am working in a team and many programmers changing the things.. and the .pbxproj file gets change everytime on every once system. Mean .pbxproj file gets changed simultaneously. Is it expected behaviour? or I am missing something.. ? – Saurabh May 25 '11 at 12:37
  • You're missing something :-) If everyone follows this rule religiously, there will be no conflicts in the project file, because everyone will change the project file based on the last change made by anyone else. You just have to make sure you do each step quickly after the next. – Philippe Leybaert May 25 '11 at 12:42
0

Remember this:

Always update before you commit.

Pratik Deoghare
  • 30,271
  • 27
  • 94
  • 143
  • There's a race condition in your advice. – Rhythmic Fistman May 25 '11 at 11:46
  • 1
    @Rhythmic Fistman: You don't seem to have made the same obverservation on @Philippe Leybaert's post, which contains the same condition. Or am I missing something? – forsvarir May 25 '11 at 11:52
  • @MachineCharmer - but when I update my copy with latest revision the .xcodeproj (or specifically I should say - project.pbxproj in .xcodeproj folder) my own changes will be lost.. won't they? – Saurabh May 25 '11 at 12:12
  • No. SVN will merge changes made by your friend with your local copy. If there is conflict SVN will let you know. – Pratik Deoghare May 25 '11 at 12:45
  • @forsvarir your use of italics and bold caught my eye. I didn't read the other post. Really I was just poking fun at svn's quaint 20th century conception of one central repository and the problems it creates. – Rhythmic Fistman May 25 '11 at 12:51
  • 1
    @Rhythmic Fistman: It's not my post, so I didn't use any bold/italics :^) I don't see how having a distributed repository would resolve the problem... but then I haven't used *git* – forsvarir May 25 '11 at 13:21
  • Oops, anyway git's great: http://stackoverflow.com/questions/1080814/git-or-mercurial-usage-in-java-projects/1081027#1081027 – Rhythmic Fistman May 25 '11 at 16:34