简体   繁体   English

在Xcode中使用Subversion

[英]Using Subversion in Xcode

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 (ie interacting with svn via Xcode's GUI). 看起来,所有Google最初针对“ 使用xcode进行颠覆 ”的结果实际上只是用于安装和配置svn和Xcode的教程,而不是实际使用两者(即通过Xcode的GUI与svn进行交互)。

Is anyone aware of a good guide that teaches the tricks and pitfalls of working with svn via Xcode's GUI? 有没有人知道一个好的指南,该指南通过Xcode的GUI教授使用svn的技巧和陷阱? 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)? 有什么能弥合最出色的Subversion版本控制书和Xcode IDE之间的鸿沟(就像在使用任何终端命令的情况下在纯Xcode GUI中一样)?

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. 我们都喜欢我们的终端命令,我们都喜欢Eclipse,但是(我的意思是最好的方式)都不是问题的重点。 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. 我更喜欢通过Xcode的IDE使用svn,而不是通过终端使用svn,就像我更喜欢(在这种情况下)在Xcode的IDE中进行编码一样,而不是使用vim和gcc。 Apple engineers spent a good bit of time implementing that SCM menu in Xcode; 苹果工程师花费了大量时间在Xcode中实现该SCM菜单。 someone has to have seen a usage guide somewhere . 某人必须在某处看过使用指南。

I used this page as a reference for setting up my XCode projects with SVN. 将此页面用作使用SVN设置XCode项目的参考。 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. 几个注意事项:我正在使用XCode 3.1.2和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. 我听说过使用SVN 1.5的问题,但是有一些我不会涉及的方法。

First off, I had a repository already set up and created the XCode project afterwards. 首先,我已经建立了一个存储库,然后创建了XCode项目。

  1. In XCode you need to set it up to know about your repository using the SCM tab in the preferences window. 在XCode中,您需要使用首选项窗口中的SCM选项卡对其进行设置,以了解您的存储库。 Enter: 输入:

    1. A Name (this is arbitrary and used for reference with XCode) 名称(这是任意的,用于XCode引用)
    2. The scheme (http or svn) 方案(http或svn)
    3. The host (ie svn.example.com) 主机(即svn.example.com)
    4. The path (the exact path to the SVN repository located on the host) 路径(到主机上SVN存储库的确切路径)
    5. The port (only if it isn't the default) 端口(仅当不是默认端口时)
    6. And a username and password used to access the repository. 以及用于访问存储库的用户名和密码。

    The URL will be auto-filled as you enter the other fields. 在输入其他字段时,URL将自动填写。 Hit "OK" when all the fields are good and XCode says it can connect. 当所有字段都正确并且XCode表示可以连接时,请单击“确定”。

  2. 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. 在底部的“常规”选项卡下,是SCM的一个选项,选择您在1中创建的存储库,然后关闭窗口。

  3. Now open SCM in the menu-bar and go to "Repositories." 现在,在菜单栏中打开SCM,然后转到“存储库”。 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. 希望您已经在基本级别上使用分支,主干和其他目录来正确构建存储库,因为XCode不支持检出根目录。 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). 因此,一次在列表中向下浏览一个目录,然后单击“签出”按钮,然后选择要检出的目录(我建议在XCode项目目录中包含“代码”或“源”或“ SVN”目录)。 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. 您不能一次签出多个目录,但是可以在第一个目录完成之前告诉下一个目录签出,并使XCode带有命令队列。

  4. Once that is all done go back to your XCode project window and "Add -> Existing Files..." to your project. 完成所有操作后,返回到XCode项目窗口,然后将“ Add-> Existing Files ...”添加到项目中。 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. 现在,您已经将SVN信息库导入了XCode项目。 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. 在这里,您随时可以进行更改,只需在文件中单击鼠标右键(如果只有1个按钮,则单击Control-Click),上下文菜单底部是用于比较,提交,更新和丢弃(还原)的SCM选项。 ) 文件。 You can also use the SCM menu in the menubar for file or project-wide updates/commits/reverts. 您也可以使用菜单栏中的SCM菜单进行文件或项目范围的更新/提交/还原。

I second the comment by the_mandrill , SVN support from within XCode is very limited, especially if you're used to Eclipse. 我第二次通过the_mandrill进行评论,XCode中对SVN的支持非常有限,特别是如果您习惯使用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. 我在项目目录中打开了一个终端窗口,并且在命令行中与SVN交互时没有任何问题。

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. 我知道这并不是您所要求的,但是我不会过多地依赖Xcode的SVN的使用,因为您可以使用它进行的操作非常有限。 It's useful for being able to do a diff or annotate direct from the IDE but not a great deal else. 能够直接从IDE进行差异或注释,但对其他方面没有多大作用。 I don't think it's any substitute for using a separate standalone client such as SmartSVN or Versions. 我认为这不能替代使用单独的独立客户端(例如SmartSVN或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. 您还必须跳过许多步骤,才能使Xcode与SVN 1.5版一起使用,因此在安装独立客户端之前需要了解这一点。 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 这是在XCode中配置Subversion的最佳教程之一-http: //iphonedevelopment.blogspot.com/2009/03/version-control-is-your-friend.html

It also teaches even to create repository in local MAC. 它还教导甚至在本地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).. 如果您想通过gui界面使用svn,那么我建议您使用eclipse + subclipse插件(与xcode上的svn相比,它具有更多的功能,更可靠,更容易)。

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 ) 您将像往常一样在xcode中工作,但是仅将eclipse用作svn客户端(通过在eclipse中创建常规项目并将其指向您的xcode项目目录)

and here is a tutorial of how to install subclipse 这是有关如何安装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. 很多人在使用内置svn客户端时遇到问题,尤其是要使新项目进入svn并能正常工作时。

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) 我创建了一个有关如何执行此操作的直接前瞻性教程,以及一个众所周知的陷阱(适用于Xcode,直到最新版本的xcode(包括Iphone 4 sdk))

http://www.sodeso.nl/?p=599 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 : 我本人一直在寻找一些好的资源,而我发现的最好的资源之一就是WWDC 2012的一段最近的视频:

Sign in here if it's not already the case : https://developer.apple.com/videos/wwdc/2012/ 如果不是这种情况, 在此处登录: https : //developer.apple.com/videos/wwdc/2012/

Then there is a video called :Session 411 - Source Control Management in Xcode 然后是一个视频:Session 411-Xcode中的源代码管理

It explains how to use version control both with GIT and Subversion. 它说明了如何在GIT和Subversion中同时使用版本控制。 It's really nice ! 这太好了 !

Hope it helps! 希望能帮助到你!

With XCode4 you can perform almost all of your SCM tasks from within the IDE itself, this is a great step forward. 使用XCode4,您可以从IDE本身执行几乎所有的SCM任务,这是向前迈出的一大步。

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 这是官方指南的链接: 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. 不幸的是,您仍然必须使用Terminal命令行将新项目添加到SCM ,以上链接中也清楚地记录了该项目。

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. 它没有告诉您的是,您还需要手动向SCM配置中添加忽略指令,否则最终将导致用户设置并在存储库中构建输出。 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. PS:我知道这个问题现在已经很老了,但是我已经为那些来到这里寻找答案的人添加了这个问题。

PPS : Terminal command line increases probability of human error, takes longer, is more complex and is less transparent to end users. PPS:终端命令行增加了人为错误的可能性,花费的时间更长,更复杂,并且对最终用户的透明度较低。 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. 总的来说,无法从XCode中向SCM添加项目的设计很差,我希望苹果公司更好,因为他们通常擅长简化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. 对于那里的命令行迷来说,您可能会感到L337,但是尝试管理一组程序员并对其代码负责,命令行不是您的朋友。

As has been mentioned in many other answers, the svn client with Xcode is quite weak (and that is being kind). 正如在其他许多答案中提到的那样,使用Xcode的svn客户端非常弱(这很友好)。

Personally, I think that running Eclipse just to get access to a svn client is a bit heavy handed. 就个人而言,我认为运行Eclipse 只是为了获得对svn客户端的访问权是有点费力的。

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) 在Mac上使用专用的svn客户端(虽然不是免费的,但是Versions和Cornerstone都非常好...还有免费的,例如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. 如果您对终端不满意,则可以编写几个要使用的关键命令的脚本,然后将它们添加到Xcode用户脚本文件夹中,然后可以从击键菜单项中触发它们,就像如果您使用的是Xcode本机客户端。 There's a ton of examples on how to do this available via Google. 通过Google提供了大量有关如何执行此操作的示例。

I came across these - no idea how well they work, but wanted to add some resources if I could: 我碰到了这些-不知道它们的工作情况如何,但是想添加一些资源,如果可以的话:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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