在 Xcode 中使用 Subversion

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1551886/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 03:11:05  来源:igfitidea点击:

Using Subversion in Xcode

svnxcodeversion-control

提问by Kevin L.

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 usingthe two (i.e. interacting with svn via Xcode's GUI).

似乎所有关于“使用 subversion 与 xcode”的初始 Google 结果实际上只是安装和配置 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? Something that bridges the gap between the most excellent Version Control with Subversionbook and the Xcode IDE (as in pure Xcode GUI withoutany terminal command use)?

有没有人知道一个很好的指南,它教你通过 Xcode 的 GUI 使用 svn 的技巧和陷阱?有什么东西可以弥补最优秀的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. 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.

我们都喜欢我们的终端命令,我们都喜欢 Eclipse,但是(我的意思是最好的方式)两者都不是问题的重点。我更喜欢通过 Xcode 的 IDE 而不是通过终端使用 svn,就像我更喜欢(好吧,对于这种情况)在 Xcode 的 IDE 中编码而不是使用 vim 和 gcc。Apple 工程师花了很多时间在 Xcode 中实现 SCM 菜单;一定有人在某处看过使用指南。

采纳答案by ruipacheco

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 交互没有问题。

回答by Oz.

I used this pageas 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!).

我使用此页面作为使用 SVN 设置我的 XCode 项目的参考。这是一个很好的起点,但我将简要介绍我所做的(因为该页面并不是真正有用!)。

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.

一些注意事项:我使用的是 XCode 3.1.2 和 Subversion 1.4.2。我听说过使用 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. Enter:

    1. A Name (this is arbitrary and used for reference with XCode)
    2. The scheme (http or svn)
    3. The host (i.e. svn.example.com)
    4. The path (the exact path to the SVN repository located on the host)
    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. Hit "OK" when all the fields are good and XCode says it can connect.

  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.

  3. 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.

  4. 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.

  1. 在 XCode 中,您需要使用首选项窗口中的 SCM 选项卡将其设置为了解您的存储库。进入:

    1. 名称(这是任意的,用于 XCode 参考)
    2. 方案(http 或 svn)
    3. 主机(即 svn.example.com)
    4. 路径(位于主机上的 SVN 存储库的确切路径)
    5. 端口(仅当它不是默认值时)
    6. 以及用于访问存储库的用户名和密码。

    当您输入其他字段时,该 URL 将自动填充。当所有字段都正常并且 XCode 说它可以连接时点击“确定”。

  2. 然后打开您的项目并在项目本身上执行“获取信息”(带有感叹号的圆形蓝色图标)。在底部的“常规”选项卡下是 SCM 选项,选择您在 1 中创建的存储库并关闭窗口。

  3. 现在在菜单栏中打开 SCM 并转到“存储库”。希望您已经在基础级别使用分支、主干和其他目录正确构建了存储库,因为 XCode 不支持检出根目录。因此,一次从列表中找到一个目录,然后单击“Checkout”按钮并选择一个目录以将其检出(我建议在 XCode 项目目录中使用“Code”或“Source”或“SVN”目录)。您不能一次检出多个目录,但您可以告诉下一个目录在第一个目录完成之前检出,并且 XCode 将命令排入队列。

  4. 全部完成后,返回您的 XCode 项目窗口,然后将“添加 -> 现有文件...”添加到您的项目中。选择您将存储库检出到的目录,我建议使用“创建文件夹引用”选项而不是“递归创建组”选项,因为添加和删除的项目将自动反映在文件夹引用中,而不是在组中。

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.

现在您已将 SVN 存储库导入到 XCode 项目中。从这里任何时候进行更改,只需在文件中右键单击(如果您只有 1 个按钮,请按住 Control 单击),并且上下文菜单底部是用于比较、提交、更新和丢弃(还原)的 SCM 选项) 文件。您还可以使用菜单栏中的 SCM 菜单进行文件或项目范围的更新/提交/恢复。

回答by the_mandrill

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.

我知道这不是你所问的,但我不会太依赖 Xcode 中 SVN 的使用,因为你可以用它做的事情非常有限。它对于能够直接从 IDE 进行差异或注释很有用,但除此之外没有其他作用。我认为它不能替代使用单独的独立客户端,例如 SmartSVN 或 Versions。

You also have to jump through a number of hoopsto 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.

为了让 Xcode 与 SVN 1.5 版一起工作,您还必须跳过许多障碍,因此在安装独立客户端之前需要注意这一点。如果有疑问,请先检查沙箱。

回答by Sagar

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 中配置颠覆的最佳教程之一 - http://iphonedevelopment.blogspot.com/2009/03/version-control-is-your-friend.html

It also teaches even to create repository in local MAC.

它还教甚至在本地 MAC 中创建存储库。

回答by Ahmed Kotb

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 tutorialof how to install subclipse

这是一个关于如何安装 subclipse的教程

回答by ronaldmathies

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

回答by Andy M

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 - Source Control Management in Xcode

It explains how to use version control both with GIT and Subversion. It's really nice !

它解释了如何在 GIT 和 Subversion 中使用版本控制。这太好了 !

Hope it helps!

希望能帮助到你!

回答by mmc

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 justto 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)
  • 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.
  • 使用 Mac 专用的 svn 客户端(Versions 和 Cornerstone 都非常好,虽然不是免费的……有免费的,比如 svnX)
  • 如果您对终端不太满意,您可以编写几个您想要使用的按键命令并将它们添加到您的 Xcode 用户脚本文件夹中,然后您可以从一个按键的菜单项中触发它们,就像如果您使用的是 Xcode 本机客户端。有大量关于如何通过 Google 执行此操作的示例。

回答by Martin Belcher - AtWrk

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.

不幸的是,您仍然必须使用终端命令行将新项目添加到 SCM,这也清楚地记录在上面的链接中。

What it does not tell you is that you also need to manually add ignore instructions to your SCM configurationotherwise 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.

它没有告诉您的是,您还需要手动将忽略指令添加到您的 SCM 配置中,否则您最终将使用用户设置并在您的存储库中构建输出。我目前正在确定列表,一旦我完成它,我会更新这个答案。

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. 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.

PPS:终端命令行增加了人为错误的可能性,需要更长的时间,更复杂,对最终用户的透明度较低。总的来说,能够从 XCode 中将项目添加到 SCM 的遗漏是糟糕的设计,我期望 Apple 通常擅长简化 UI。对于那里的命令行爱好者,您可能会感到 L337,但尝试管理一个程序员团队并负责他们的代码,命令行不是您的朋友。

回答by warren

I came across these - no idea how well they work, but wanted to add some resources if I could:

我遇到了这些 - 不知道它们的效果如何,但如果可以的话,我想添加一些资源: