将文件移动到Xcode中的实际文件夹中 [英] Moving Files into a Real Folder in Xcode

查看:324
本文介绍了将文件移动到Xcode中的实际文件夹中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我开始我的项目时,我很高兴在Xcode中使用组,而不是文字文件夹:由于我在Xcode中使用浏览器来访问所有内容,因此组织得很好,我很高兴。



然而,现在项目即将被共享用于版本控制,项目文件夹本身就是一个恐怖表演,那些试图通过终端进行扫描的项目文件夹,大约有300个文件,其中一半以上是图形。



我正在尝试重新组织事物,创建真正的文件夹并将其导入Xcode。不幸的是,Xcode不允许我们按照与团队的方式一起工作。例如,如果我右键单击实际添加的文件夹(蓝色,而不是黄色),并选择添加现有文件,它们实际上并不会放在该文件夹中,它将它们放在根目录中。



同样,我不能将文件从一个虚拟文件夹(一个组)移动到一个真正的文件夹中:Xcode不认为真正的文件夹是有效的地方移动东西。 / p>

我缺少什么?我如何说服Xcode让我按照我使用组的方式使用文件夹?这里有一个有些类似的问题,但是,由于我正在使用现有的文件,它并没有解决我的问题。

解决方案

2016:布兰顿以下的答案是一个更好的解决方案。当这个答案在2010年创建时,这是我能找到的唯一选择。我现在建议布兰登的答案,如下。






事实证明,将文件移动到真实的文件夹当然可以,尽管不是那么简单。



我从这里提到了一个问题的基本信息, Xcode组织文件和文件夹(核心数据模型对象 - iPhone) ,但学习了重要的事情。



进程



移动文件是一个两步的过程,具有多个子步骤:


  1. 告诉Xcode你希望文件在哪里




    • 右键单击要移动的文件或文件组,然后从显示的上下文菜单中选择获取信息。出现群组信息文件信息窗口。



    • 点击路径区域的窗口的最右侧选择按钮。出现一个对话框。



    • 导航到要移动文件的文件夹。如果需要,请创建新建文件夹。点击对话框右下角的选择按钮,然后关闭组信息/文件信息窗口。



    • 组中的文件/文件的名称将变为红色,表示Xcode在您指定的位置找不到。




  2. 移动实际文件




    • 在Finder(或Git)中将您在步骤1中选择的文件移动到您想要的文件夹中。



    • 切换回Xcode。文件/组应该再次变黑。如果还有红色,那么你错过了一些东西到正确的文件夹。




< h2>提示

在这个项目中调整〜300个文件时,我学到了一些重要的东西:




  • 某些文件拒绝移动;也就是说,当您导航到新目的地时,选择按钮被禁用,新建文件夹按钮也是如此。解决方案虽然不知道为什么会有所作为,但首先要使用Xcode将这些文件放在一个组中(右键单击文件并选择,然后给组一个名称),然后将该组移动到新的位置。在Finder中实际移动文件后,您可以将其从组中删除(通过将其拖动到新的父组/文件夹中并删除组)。



  • 在完成了许多文件的步骤2后,每隔几分钟停止并建立一个文件。这个构建将告诉你,如果你已经搞砸了任何东西,使之更容易返回并修复它,然后再造成太多的伤害。



  • 如果文件不会移动到您希望他们的位置;我有一个时间移动一些早期在Classes文件夹中创建的文件,您可以简单地将它们从查找器中的旧地方拖出,像桌面一样方便,在Xcode中删除对它们的引用,然后通过右键/控制单击重新导入添加现有文件选项。



  • 如果过去您已经使用Xcode删除对文件的引用,而不将其移动到此项目中的垃圾箱,那么将找到不需要移动但只是坐在那里的文件。要小心,你不要做我做的,混淆我正在移动的一组文件的名称和较旧的,不再链接的文件,坚持Xcode导入它们,因为你认为它是密集的。 li>


希望这有助于未来的人。我很惊讶,这是一样困难,偶尔也是棘手的。


When I started my project I was happy to use Groups in Xcode rather than literal folders: Since I'm using the browser in Xcode to access everything, stuff was nicely organized and I was happy.

However, now that the project is about to be shared for version control, the project folder itself is a horror show for those trying to scan it via a terminal, about 300 files, over half of which are graphics.

I'm trying to now reorganize things, creating real folders and importing them into Xcode. Unfortunately Xcode doesn't let me work with them the way it does with groups. For example, if I right-click on an actual added folder (blue, not yellow) and choose to add existing files, it doesn't actually put them in that folder, it puts them in its root.

Similarly, I can't move a file from a faux-folder (a group) into a real folder: Xcode doesn't consider the real folders to be valid places to move stuff to.

What am I missing? How can I convince Xcode to let me use the folders the way I use groups? There's an answer here to a somewhat similar question, but it doesn't actually solve my problem since I'm working with existing files.

解决方案

EDITED DECEMBER 2016: Brandon's answer below is a better solution now. Back when this answer was created in 2010 this was the only option I could find. I now suggest Brandon's answer, below.


It turns out that moving files into real folders is certainly possible, though not as simple as it should be.

I got the basic information from a question here, Xcode organising files and folders (core data model objects - iPhone), but learned important things along the way.

The Process

Moving the files is a two-step process with multiple sub-steps:

  1. Tell Xcode where you want the files to be:

    • Right/Control-click on the file or file group that you'd like to move and choose Get Info from the contextual menu that appears. The Group Info or File Info window appears.

    • Click the Choose button on the far right side of the window in the Path area. A dialog box appears.

    • Navigate to the folder you want the files to be moved to. Create a New Folder if needed. Click the Choose button in the bottom-right corner of the dialog box, then close the Group Info/File Info window.

    • The names of the file/files in the group will turn red to indicate that Xcode can't find them in the place you specified.

  2. Move the actual files

    • In the Finder (or Git) move the files you selected in step 1 into the actual folders you want them in.

    • Switch back to Xcode. The files/groups should all have turned black again. If any are still red then you've missed moving something to the right folder.

Tips

I learned a couple of important things while adjusting the ~300 files in this project:

  • Some files refuse to move this way; that is, when you navigate to the new destination the Choose button is disabled, as is the New Folder button. The solution, though I don't know why it makes a difference, is to first use Xcode to put those files in a Group (right/control-click the files and choose Group, and give the group a name) and then move the group to the new location. After you're actually moved the files in the Finder you can remove them from the group (by dragging them into the new parent group/folder and deleting the group).

  • Stop and build every few minutes, after completing step 2 for a number of files. The build will tell you if you've screwed anything up so far, making it easier to go back and fix it before you've done too much damage.

  • If the files won't move to where you want them to — I had a devil of a time moving some files that had been created early-on in the Classes folder — you can simply drag them out of their old place in the finder to someplace handy like the desktop, delete references to them in Xcode, and then re-import them via the right/control-click Add Existing Files option.

  • If in the past you've used Xcode to delete references to files without also moving them to the trash in this project, you'll find files that don't have to be moved but at just sitting there. Be careful that you don't do what I did, confusing the names of a current group of files I was moving and the older, no-longer-linked files, insisting that Xcode import them because you thought it was being dense.

Hope this helps some future person. I'm surprised that it was as difficult and occasionally tricky as it was.

这篇关于将文件移动到Xcode中的实际文件夹中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆