如何在 Xcode 6 上设置 svn 存储库?

how to setup svn repository on Xcode 6?

我刚开始使用 Xcode 并尝试在远程 windows 服务器上添加一个 Subversion 存储库。当我输入 Subversion 存储库的位置路径时,它显示以下错误消息:

错误信息:

“无法访问主机。”

请问有人能帮忙吗?谢谢

即使没有 Xcode,设置 svn 源代码控制也总是很痛苦,Apple 无法帮助它集成到 Xcode。它从版本到版本都在变化,最新版本与版本 5 相似,因此 Xcode 6 中也是如此。 这个解决方案的唯一问题是我们总是必须结合命令行和 Xcode GUI 步骤,但这是唯一可行的解​​决方案,所以我们将遵循这个,但在可能的情况下使用 Xcode。

由于我做了几次,但总是 运行 遇到各种问题,我决定做一个详细和清晰的最新描述。

The server side

即使您可以在您的计算机上安装 svn 服务器,即使您单独工作,这也不是一个安全的解决方案。如果硬盘出现故障或发生任何事故,您可能会失去多年的工作成果。所以在单独的计算机上制作它。 您需要在其上安装 svn 服务器并登录。您可以检查一下,只需 ssh 进入您的服务器并使用终端中的命令

which svn

如果你得到一个版本号,你可能在该服务器上有一个活的存储库目录的 svn,你可以访问它。确切的位置取决于您的安装,但在我们的例子中,主存储库目录是:https://myserver.me.com/Library/Subversion/Repository/

您将在此目录下创建新的存储库,例如 https://myserver.me.com/Library/Subversion/Repository/MyNewApp


1.创建新存储库

登录到您的服务器(在我们的示例中为 myserver.me.com),然后打开终端实用程序并使用 svnadmin create 命令创建一个 Subversion 存储库。 例如,如果您想要在现有位置 /Library/Subversion/Repository/ 中创建一个名为 MyNewApp 的存储库,您可以输入命令:

svnadmin create /Library/Subversion/Repository/MyNewApp

这将创建存储库的主要结构。我们从服务器注销以避免任何问题,并且从现在开始不直接使用它,只从客户端使用它。

The client side

2。创建文件夹结构

Note: Creating a hierarchy for your repository is optional. It's not needed in order to get svn to work properly, but if you're planning on keeping multiple projects under source control, then it's a good idea to get organized before you start importing those projects.

我们将在客户端准备文件夹结构,然后使用名为 "import".

的 svn 命令将其传输到服务器

1.First 在您客户端的任何位置创建一个新的临时文件夹 - 例如在您的桌面上 - 在我们的案例中使用 Finder 中的 project/repository 名称 MyNewApp:

MyNewApp

然后在其中创建另外 3 个文件夹,名称完全相同:

trunk
branches
tags

2.Import svn 服务器的文件夹结构

使用终端实用程序登录到您的客户端并使用 "cd" 命令进入项目文件夹:

cd MyNewApp

Tip: The easiest way to get the full path to a folder into Terminal without risking typing errors is to first type the cd command and enter a space, and then drag the folder from the Finder and drop it at the end of the Terminal command line.

3.Then 从终端使用 svn 导入命令:

svn import . https://myserver.me.com/Library/Subversion/Repository/MyNewApp -m "Initial import of directories for MyNewApp project."

svn import . svn+sshtunnel://yourLoginName@194.149.155.124/Library/Subversion/Repository/MyNewApp -m "Initial import of directories for MyNewApp project."

第二种是使用 ssh 密钥最安全的用法,其中 194.149.155.124 是服务器的 IP 地址。 svn+sshtunnel:// 表示它使用 svn 和 sshtunnel 但它可以是任何其他取决于登录机制,如 https://svn:// “。”在 "import" 命令很重要之后,它表示您所在的同一文件夹。

如果导入成功,您应该会看到如下内容:

Adding trunk 
Adding branches
Adding tags

Committed revision 1.

Note: This means this is the first committed version you loaded to the server to MyNewApp repository and it's under revision control by svn with a message just referencing what you did, and you could use what you like. Now that you have imported the directory structure for your project into the repository, you can now delete the MyNewApp1 directory on your computer that you just created. Doing this will help to prevent confusion later, when you import the real project.

3.Import将Xcode项目导入svn

使用终端导航到您的 Xcode 项目并再次确保您位于项目文件夹中

cd MyNewApp

然后再次使用以下 svn 命令:

svn import . https://myserver.me.com/Library/Subversion/Repository/MyNewApp/trunk/MyNewApp1  -m "Initial import of MyNewApp1 project."

或您计算机上的确切位置 /Users/myUserName/Apps_Developing/myNewApp

svn import -m "New Import"  /Users/myUserName/Apps_Developing/myNewApp https://myserver.me.com/Library/Subversion/Repository/MyNewApp/trunk/MyNewApp1

如果导入成功,您应该会看到添加文件的长列表...

Note: This means that you import the MyNewApp1 (you could use any name) project to the trunk under svn. The trunk extension is important because of naming convention used by Xcode too. Again you can include any comment you want in the quotation marks, but be sure your comment will be meaningful to anyone using the repository.


4.Add 存储库在 Xcode

现在启动 Xcode 并转到 Preferences --> Accounts 并使用左下角的“+”添加新存储库

+ Add Repository...

输入仓库地址

https://myserver.me.com/Library/Subversion/Repository/MyNewApp

Note: Don't use the trunk etc. you need the root of the repository here!

5.Checkout 创建工作副本的项目

在 Xcode 中转到 Source Control --> Check Out...

输入 t运行k 的存储库地址(或分支或标签,如果您之前使用过它们)

https://myserver.me.com/Library/Subversion/Repository/MyNewApp/trunk

然后给出工作副本文件夹的名称及其位置

Note: trunk is important!!! Just type it after the root, if you miss it there will be trunk etc. folders in your folder! Directory name is as you like for example MyNewAppWorking...then choose location on your computer like Apps_Developing in our case.