向 Xcode 项目添加文件夹未正确添加

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/39983391/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 18:23:03  来源:igfitidea点击:

Adding Folder to Xcode Project is not Properly added

xcodereferencedirectoryproject

提问by kiran

Team,

团队,

I created the new Project, on project folder right click open show in finder there I created "ViewControllers" Folder and again right click Add files to "ProjectName" then I added the created folder i.e., "ViewControllers" which is in blue colour "Expected yellow colour folder" that is reference to my project folder the blue colour folder is not. In blue colour folder when i try to added new file its added an empty File.

我创建了新项目,在项目文件夹上右键单击在 finder 中打开显示我创建了“ViewControllers”文件夹,然后再次右键单击将文件添加到“ProjectName”然后我添加了创建的文件夹,即“ViewControllers”,它是蓝色的“预期黄色文件夹”,这是对我的项目文件夹的引用,而蓝色文件夹不是。在蓝色文件夹中,当我尝试添加新文件时,它添加了一个空文件。

How can i reference my added folder to the Xcode project? how to avoid this blue colour folder class in my project?

如何将我添加的文件夹引用到 Xcode 项目?如何在我的项目中避免这个蓝色文件夹类?

Your inputs are highly appreciable.

您的意见是非常可观的。

回答by Maximilian G?tzfried

If your Xcode project looks like this…

如果您的 Xcode 项目如下所示……

Xcode project with folder reference

带有文件夹引用的 Xcode 项目

…then you've added your ViewControllersfolder as folder reference.

...然后您已将您的ViewControllers文件夹添加为文件夹参考。

To change this folder to a group follow these steps:

要将此文件夹更改为组,请执行以下步骤:

  • Right click on ViewControllers
  • Choose Deletein the context menu
  • Choose Remove Referencein the dialog that popped up. The folder will be removed from your Xcode project but not from the file system.
  • Then choose Add Files to <YourProjectName>…in the Filemenu
  • Find your ViewControllersin the file system
  • Before clicking Addmake sure that the option Create groupsis selected
  • Click Add
  • 右键单击 ViewControllers
  • 选择Delete在上下文菜单
  • Remove Reference在弹出的对话框中选择。该文件夹将从您的 Xcode 项目中删除,但不会从文件系统中删除。
  • 然后Add Files to <YourProjectName>…File菜单中选择
  • ViewControllers在文件系统中找到你的
  • 在单击之前Add确保Create groups选择了该选项
  • 点击 Add

You've added your ViewControllersfolder as group:

您已将ViewControllers文件夹添加为组:

Xcode project with folder group

带有文件夹组的 Xcode 项目



Important note regarding Xcode 8:

关于 Xcode 8 的重要说明:

The option Create groupsmight not be visible right away. Apple moved this in Xcode 8 to the bottom of the Add Files to…dialog:

该选项Create groups可能不会立即可见。Apple 在 Xcode 8 中将其移至Add Files to…对话框底部:

Collapsed options

折叠选项

This reveals the option Create groups:

这揭示了选项Create groups

Expanded options

扩展选项