如何在 Xcode 4 中向源代码管理添加新项目?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5618686/
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
How to add a new project to source control in Xcode 4?
提问by TheLearner
How do I add a new project to source control (SVN) using Xcode 4?
如何使用 Xcode 4 将新项目添加到源代码管理 (SVN)?
回答by TheLearner
Open Organizer. Click on the root of your SVN repository in the tree on the left. Click on Import on the bottom right and choose the directory from finder that you want to add and click Import.
打开管理器。单击左侧树中 SVN 存储库的根目录。单击右下角的导入,然后从查找器中选择要添加的目录,然后单击导入。
This will add the project to SVN
这会将项目添加到 SVN
回答by VonC
The XCode 4 documentationrecommend using command-line tools or a utility program to set up a Git or Subversion repository.
该的XCode 4文档建议使用命令行工具或实用程序来设置一个Git或Subversion库。
To set up a Subversion repository using the command line1/ Open the Terminal utility and use the
svnadmin
create command to create a Subversion repository.
For example, if you want a repository namedSketch_svn
in the existing location/Users/myUserName/Repositories
, you would enter the command:
使用命令行设置 Subversion 存储库1/ 打开终端实用程序并使用
svnadmin
create 命令创建一个 Subversion 存储库。
例如,如果您想要Sketch_svn
在现有位置命名的存储库/Users/myUserName/Repositories
,您可以输入命令:
svnadmin create /Users/myUserName/Repositories/Sketch_svn
Tip: The easiest way to get the full path to a folder into Terminal without risking typing errors is to first type the command (
cd
in this case), enter a space, and then drag the folder from the Finder and drop it at the end of the Terminal command line.Note that the directory
/Users/myUserName/Repositories/
must already exist before you execute this command. You can use the Finder or amkdir
command to create the directory.2/ In another location—not in the repository you just created—create a folder to hold a temporary copy of the project. In that folder, create three additional folders named
branches
,tags
, andtrunk
.3/ Create a new Xcode project in the trunk folder, using Xcode, or put your existing project in the
trunk
folder, using the command line or the Finder.4/ Use the svn import function to import your project into the repository you created and place it under Subversion source control.
For example, if your temporary copy is in/Users/myUserName/Projects/Sketch_tmp
, you would enter the following command in Terminal:
提示:在不冒输入错误风险的情况下将文件夹的完整路径输入终端的最简单方法是首先输入命令(
cd
在这种情况下),输入一个空格,然后从 Finder 中拖动文件夹并将其放在末尾终端命令行。请注意,在
/Users/myUserName/Repositories/
执行此命令之前,该目录必须已经存在。您可以使用 Finder 或mkdir
命令来创建目录。2/ 在另一个位置——不是你刚创建的存储库——创建一个文件夹来保存项目的临时副本。在该文件夹中创建一个名为三个文件夹
branches
,tags
和trunk
。3/ 在trunk 文件夹中创建一个新的Xcode 项目,使用Xcode,或者将您现有的项目放在
trunk
文件夹中,使用命令行或Finder。4/ 使用 svn 导入功能将您的项目导入您创建的存储库中,并将其置于 Subversion 源代码控制之下。
例如,如果您的临时副本在 中/Users/myUserName/Projects/Sketch_tmp
,您将在终端中输入以下命令:
svn import /Users/myUserName/Projects/Sketch_tmp \
file:///Users/myUserName/Repositories/Sketch_svn -m "Initial import"
Notes
- The backslash at the end of the first line indicates that the command is continued on the next line. You can omit the backslash and type the entire command on one line. If you do use the backslash, be sure there are no spaces following it before you press Return.
- There are three forward slashes in the string
file:///
.- If you type the entire command on one line, be sure there is a space before
file:///
.- You can include any comment you want in the quotation marks, but be sure your comment will be meaningful to anyone using the repository.
5/ In the repositories organizer in Xcode, click the Add (
+
) button at the bottom of the navigator pane, and choose Checkout Repository to create a working copy.
笔记
- 第一行末尾的反斜杠表示该命令在下一行继续。您可以省略反斜杠并在一行中键入整个命令。如果确实使用了反斜杠,请确保在按 Return 之前没有空格。
- 字符串中有三个正斜杠
file:///
。- 如果在一行中键入整个命令,请确保在
file:///
.- 您可以在引号中包含您想要的任何评论,但请确保您的评论对使用存储库的任何人都有意义。
5/ 在 Xcode 的存储库管理器中,单击
+
导航器窗格底部的添加 ( ) 按钮,然后选择 Checkout Repository 以创建工作副本。
回答by Caleb
Use Terminal. At the command line, you can use the svn import
command to add the project to your repository.
使用终端。在命令行中,您可以使用该svn import
命令将项目添加到您的存储库中。
From the way you worded your question, I'm assuming that your subversion repository already exists. You'll follow the same basic steps outlined in Add Git or Subversion Version Control to an Existing Projectin the Xcode 4 Users Guide, except that instead of creating a whole new repository you'll just add a new directory to your existing repository.
从您提出问题的方式来看,我假设您的 subversion 存储库已经存在。您将按照Xcode 4 用户指南中的将 Git 或 Subversion 版本控制添加到现有项目中概述的基本步骤进行操作,不同之处在于您只需向现有存储库添加一个新目录,而不是创建一个全新的存储库。
It's handy that Xcode has support for version control, but it's not a full-featured GUI version control client. You should still know how to manage your repository using the svn command line program. Alternately, you can get a GUI front end like Versions. Either way, you should have (and have read) the Subversion Book. There's a lot more to using version control than just checking files in and out, and you need to know how it works and how best to use it if it's going to help you.
Xcode 支持版本控制很方便,但它不是一个功能齐全的 GUI 版本控制客户端。您仍然应该知道如何使用 svn 命令行程序管理您的存储库。或者,您可以获得像Versions这样的 GUI 前端。无论哪种方式,您都应该拥有(并且已经阅读)了Subversion Book。使用版本控制不仅仅是检入和检出文件,而且您需要知道它是如何工作的以及如何最好地使用它,如果它对您有所帮助。