简体   繁体   中英

How to work with branches in XCode (SVN)

I successfully set up SVN and XCode, it's really cool ! I commit, update, I even tag (in the Terminal though...) ! All this is pretty easy Now I'd like to work with different branches, but I'm a bit confused.

I'v followed this tutorial , and it has a section about branching. What it says is to use this script :

#!/bin/ksh
# A script to branch a SVN trunk
reporoot=/Library/Subversion/Repository/
projdir=Projects

# Prompt for repository name
print -n "Enter repository name:"
read repo

# Prompt for project name
print -n "Enter project name:"
read project

# Prompt for branch name
print -n "Enter branch name:"
read branch

# Create branch
svn copy file://$reporoot/$repo/$projdir/$project/trunk file://$reporoot/$repo/$projdir/$project/branches/$branch -m "Creating a branch of the ‘$project‘ project."

echo
echo Creation of a branch of the $project project complete!
echo

But what I see is it's just a shell script that copies the current trunk to a branch (like a tag). And so if I do this, I will still be committing in the trunk no ?

Do you have any idea of a way to be able to "switch" easily between branches, for updates and commit ?

Thank you very much.

subversion doesn't have a branch system. This is why you usually see a folder with "trunk", "tags" and "branches" in it. If you want to be able to switch between branches and the trunk effectively, you would probably have to create a symlink to the branch you are using. If you later wish to switch branches, you simply re-create this symlink.

I am not sure whether Xcode likes this though, or not.

Try XCode 4, it allows to create branches, switch and merge them in full mode, not the way XCode 3 used to do it.

UPDATED: You should use svn switch after you create your new branch. It will update you working copy.

Example:

svn switch http://slitvinov@192.168.1.117:8080/svn/alb.iphone/Branches/SuperFastAlgo

Full description is here

I would use Git over SVN and use GitX. You'll have a much easier time working with branches, especially if you want to use them practically and not spend half an hour on merges. The XCode3 SCM integration isn't particularly full-featured. If at all possible, I'd try XCode4 with Git, and clone and add vendor libraries as submodules. (This is all somewhat SOP as of 2012).

You can always use git svn commands ( sample tutorial ).

There's also an Objective-C .gitignore Github project . Having the Git repo only physically in the project root also is a big plus.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM