Xcode 移动到垃圾箱和删除引用有什么区别?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10740126/
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's the difference between Xcode's move to trash and remove reference?
提问by itenyh
When I want to delete file in Xcode. Between "move to trash" and "remove reference" which one should I choose?
当我想删除 Xcode 中的文件时。在“移至垃圾箱”和“删除参考”之间,我应该选择哪一个?
I always choose move to trashbefore cause I thought it will definitely delete the real file. But not sure if that's right. So what is the difference between them?
我总是选择移动到垃圾箱之前,因为我认为它肯定会删除真正的文件。但不确定这是否正确。那么它们之间有什么区别呢?
回答by DrummerB
Xcode stores references to the files that make up your project in the project file, namely, the projectName.xcodeproj file. Theoretically your source and resource files that make up your project could be all over your harddisk; of course that's not a good practice.
So, when you add an existing file to your project, Xcode asks whether you want to copy it into your project's folder, which is usually what you should do. So, when you go to delete a file Xcode will ask you whether you only want to remove the referencefrom your project (and keep the file wherever it lives on your drive) or if you want to remove the file as well.
Xcode 在项目文件中存储对组成项目的文件的引用,即 projectName.xcodeproj 文件。理论上,构成项目的源文件和资源文件可能遍布硬盘;当然,这不是一个好习惯。
因此,当您将现有文件添加到项目时,Xcode 会询问您是否要将其复制到项目的文件夹中,这通常是您应该做的。因此,当您删除文件时,Xcode 会询问您是否只想从项目中删除引用(并将文件保留在驱动器上的任何位置),或者是否也想删除该文件。
Basically if you check "Copy to project" when adding the file, you should chose "Move to Trash" when deleting, otherwise pick "Remove Reference". This latter option will leave the file in place and just remove the reference to it.
基本上,如果您在添加文件时选中“复制到项目”,则在删除时应选择“移至废纸篓”,否则选择“删除引用”。后一个选项将保留文件并删除对它的引用。
回答by Honey
Not a direct answer to this question, but very good to know. ???I created a file named Device.swift in my branch and added some code to it. Then my colleague also created the same file Device.swift in his branch and got it merged before I got my chnages merged.
不是这个问题的直接答案,但很高兴知道。???我在我的分支中创建了一个名为 Device.swift 的文件并添加了一些代码。然后我的同事也在他的分支中创建了相同的文件 Device.swift 并在我合并我的 chnages 之前合并了它。
What will happen is that both in my xcodeproj/project.pbxproj
file there was something like: ??
会发生什么是在我的xcodeproj/project.pbxproj
文件中都有类似的内容: ??
5C5809E72257D81500D4CBB2 /* Device.swift in Sources */
While in the master branch which had his changes, there was:
而在有他的变化的主分支中,有:
26E3A7A5226F6E13001B176C /* Device.swift in Sources */
?
We'll both have Device.swift
. Xcode will see this as a merge conflict, since we've both changed the same line. ??If you just let them both be there, then in your Xcode you'll probably end up seeing Device.swift
twice and it won't compile. ???
? 我们都会有Device.swift
。Xcode 会将此视为合并冲突,因为我们都更改了同一行。??如果你只是让它们都在那里,那么在你的 Xcode 中你可能最终会看到Device.swift
两次并且它不会编译。???
It would also be more of a problem if I added Device.swift
in /Models/Devices while he has it added in /Modell/Gadgets.
如果我Device.swift
在 /Models/Devices 中添加而他在 /Modell/Gadgets 中添加了它,那也将是一个更大的问题。
Solution:Remove all references to: 5C5809E72257D81500D4CBB2 /* Device.swift or the other. I'm not 100% sure how to decide which one you should remove so I got a copy of my Device.swift
before and then start deleting.
解决方案:删除对以下所有引用: 5C5809E72257D81500D4CBB2 /* Device.swift 或其他。我不是 100% 确定如何决定应该删除哪个,所以我得到了我Device.swift
之前的副本,然后开始删除。
And also if files are in two different directories then you'd have to manually delete one of them. Whichever you prefer
而且,如果文件位于两个不同的目录中,则您必须手动删除其中之一。无论你喜欢哪个