Xcode 首选项中的“源树”是什么,我可以用它做什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4982133/
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
What is "Source Tree" in the Xcode preferences and what can I do with it?
提问by realstuff02
I've been recently researching how I can manage source files in a project or multiple projects. I've read that Xcode has a built-in support for using svn, and will support git as well, both of which I found to be very useful.
我最近一直在研究如何管理一个或多个项目中的源文件。我读到 Xcode 内置了对使用 svn 的支持,并且还将支持 git,我发现这两者都非常有用。
The one thing I couldn't understand clearly is about Source Trees described in Xcode Project Management Guide. Here is my theory, but as I couldn't really verify this from anywhere (as far as I could tell), I would really like if someone could say what I'm missing, if any.
我无法清楚地理解的一件事是关于 Xcode 项目管理指南中描述的源树。这是我的理论,但由于我无法从任何地方真正验证这一点(据我所知),我真的很想有人能说出我遗漏了什么,如果有的话。
- A Source Tree in Xcode preferences is more like
a root
of a source tree, which is a folder in my local file system. - I can use any files in any of my Xcode projects, even if the files are not in the project folders, if I can specify the files' location related to one of my source trees.
- Now someone has the same project folder that is synchronized with mine. She has all files in the project folder, but the files referenced by a relative location to the source tree may exist out of the project folder.
- But she has a source tree, with the same
Setting Name
to mine, (but absolutely in a different folder in her local file system), and if she has the file in the same relative location, then her Xcode can access the file without a problem.
- Xcode 首选项
a root
中的源树更像是源树,它是我本地文件系统中的一个文件夹。 - 我可以在我的任何 Xcode 项目中使用任何文件,即使这些文件不在项目文件夹中,只要我可以指定与我的源树之一相关的文件位置。
- 现在有人拥有与我同步的相同项目文件夹。她拥有项目文件夹中的所有文件,但源树的相对位置所引用的文件可能存在于项目文件夹之外。
- 但是她有一个源代码树,与我的相同
Setting Name
,(但绝对在她本地文件系统的不同文件夹中),如果她在相同的相对位置拥有该文件,那么她的 Xcode 可以毫无问题地访问该文件。
So is this correct, and we use source trees because it enables us collaborating with files outside the project folder?
那么这是否正确,我们使用源代码树是因为它使我们能够与项目文件夹之外的文件进行协作?
And even if the files outside the project folder is referenced by a relative path to the project folder itself (not to a source tree), if these files are all managed by SVN so they exist in the same relative location to the project folder in everyone's environments, then I wouldn't need source trees, right?
即使项目文件夹外的文件被项目文件夹本身的相对路径引用(而不是源树),如果这些文件都由 SVN 管理,那么它们存在于每个人的项目文件夹的相同相对位置环境,那么我就不需要源树了,对吧?
采纳答案by MHC
I never think I am an expert of Xcode, but it seems your question hasn't been answered for a while, so maybe it's worth commenting what I could say:
我从不认为我是 Xcode 的专家,但您的问题似乎有一段时间没有得到解答,所以也许值得评论一下我能说的话:
What you described is pretty much about it. Think is as an environmental variable of an operating system. Typically in a build system made by Autotools, for example, files are referenced by relative paths, such as $PROJECT_HOME/src/common/error.cpp
. It doesn't matter where $PROJECT_HOME
is in each user's local file system, as long as files are accessible by their relative paths to the user's $PROJECT_HOME
directory.
你描述的差不多。Think 是操作系统的环境变量。例如,通常在 Autotools 制作的构建系统中,文件由相对路径引用,例如$PROJECT_HOME/src/common/error.cpp
. $PROJECT_HOME
只要文件可以通过它们到用户$PROJECT_HOME
目录的相对路径访问,每个用户的本地文件系统中的位置并不重要。
And yes, you don't need to use source tree if the entire folder hierarchy used for a project is referenced by relative paths to the project home and somehow it is certain that everyone has the same files in the same location (for example, because a version control repository contains every files in a chunk as you said).
是的,如果用于项目的整个文件夹层次结构由项目主目录的相对路径引用,并且以某种方式确定每个人在同一位置拥有相同的文件(例如,因为如您所说,版本控制存储库包含块中的每个文件)。
However, I think it's the best to keep all files inthe project home folder, unless they are used across multiple projects, and therefore your version control repository only contains a single root directory (the project home) for your project. If there are files that are best to be shared by multiple projects, then I would have a separate repository for those files. In this case all of your coworkers must use the same protocol, say, having a source tree with the same setting name and put all project homes retrieved from your version control server directly under the source tree (so files outside a project home can be referenced in relation to the source tree for all programmers).
但是,我认为最好将所有文件保存在项目主文件夹中,除非它们在多个项目中使用,因此您的版本控制存储库仅包含项目的单个根目录(项目主目录)。如果有最好由多个项目共享的文件,那么我将为这些文件创建一个单独的存储库。在这种情况下,您的所有同事都必须使用相同的协议,例如,拥有一个具有相同设置名称的源树,并将从版本控制服务器检索的所有项目主页直接放在源树下(因此可以引用项目主页之外的文件与所有程序员的源代码树有关)。
The most of my answer is kind of rephrasing what you already described, but that's how I use the source trees
feature in Xcode myself. Maybe others can tell you more about it.
我的大部分答案是重新表述您已经描述的内容,但这就是我source trees
自己在 Xcode 中使用该功能的方式。也许其他人可以告诉你更多关于它的信息。