简体   繁体   English

Xcode 项目文件未出现在项目导航器中

[英]Xcode Project Files not appearing in Project Navigator

Strange problem here...my project's Swift files, Main.Storyboard, additional images, delegate, etc. files are all missing from Xcodes Project Navigator.这里有一个奇怪的问题……我的项目的 Swift 文件、Main.Storyboard、附加图像、委托等文件都从 Xcodes Project Navigator 中丢失了。

What is really strange is that the project builds fine and I can also select them from the top of the main editor window even though they are not displayed on the left in the Project Navigator.真正奇怪的是项目构建得很好,我也可以从主编辑器窗口的顶部选择它们,即使它们没有显示在项目导航器的左侧。

When I open my project, the files appear for about 1/2 a second, and then the list is condensed to the blue target file at the top and about 7 images.当我打开我的项目时,文件出现大约 1/2 秒,然后列表被压缩到顶部的蓝色目标文件和大约 7 个图像。 (I cannot post a picture because my reputation is not high enough.) (因为我的名声不够高,我无法发布图片。)

I've quit and reopened Xcode and also performed a few restarts, but I still can't select them...even though they're apparently there!我已经退出并重新打开 Xcode 并重新启动了几次,但我仍然无法选择它们......即使它们显然在那里! Any ideas?有任何想法吗?

For me the issue was different.对我来说,问题是不同的。 My search bar was empty but I had mistakenly selected the clock icon in the search bar at the bottom of the navigator.我的搜索栏是空的,但我错误地选择了导航器底部搜索栏中的时钟图标。

Unselected it looks like this未选中它看起来像这样

在此处输入图片说明

Selected it look like this选择它看起来像这样

在此处输入图片说明

The clock icon filters the files for files that have been recently used and therefore, hides a number of your files.时钟图标会过滤最近使用过的文件,因此会隐藏您的许多文件。

May be you need check the Project Navigator's bottom, there is a search bar.可能您需要检查 Project Navigator 的底部,有一个搜索栏。

If the search bar had some keywords, the Project Navigator would only show the files which file's name contain the keyword(s), and you can't clear the keyword by only reopen Xcode.如果搜索栏有一些关键字,Project Navigator 只会显示文件名包含关键字的文件,并且您不能仅通过重新打开 Xcode 来清除关键字。

When you open Xcode, Xcode will initial the search bar with nothing and you can see the complete files, after initial had done, Xcode will load last close time's state for the search bar and filter files, so that's why When I open my project, the files appear for about 1/2 a second .当您打开 Xcode 时,Xcode 将初始化搜索栏,您可以看到完整的文件,初始化完成后,Xcode 将加载搜索栏和过滤文件的上次关闭时间状态,这就是为什么When I open my project, the files appear for about 1/2 a second

在此处输入图片说明

Untick this timer icon at the bottom of navigator in case you have selected it如果您选择了导航器底部的此计时器图标,请取消选中它

I solved this problem by removing a copy of the file that was being referenced by the code module where the error was occurring but was not being referenced by the project file in Project Navigator.我通过删除发生错误的代码模块引用但未被项目导航器中的项目文件引用的文件副本解决了这个问题。 Explanation: I had long ago moved a file to a different directory and changed the reference in the project, but had not deleted the original version of the file.说明:我很早以前把一个文件移到了不同​​的目录,并在项目中更改了引用,但没有删除文件的原始版本。 The file still existed on the file system in the original location but was being referenced by the project file and Project Navigator (.xcodeproj) in a new location.该文件仍然存在于原始位置的文件系统上,但被项目文件和项目导航器 (.xcodeproj) 在新位置引用。 The referencing code module still found the file in then old location and did not update the pointer to the new location automatically.引用代码模块仍然在旧位置找到文件,并且没有自动更新指向新位置的指针。 Simply deleting the file in the old location fixed this issue for me.只需删除旧位置中的文件即可为我解决此问题。

I debugged this by drilling into the referenced file by right clicking on the object name in code which opened up the module in a code window and then right clicking on the code and selecting "Show in finder".我通过右键单击代码中的对象名称并在代码窗口中打开模块,然后右键单击代码并选择“在查找器中显示”来钻取引用文件来调试它。 I then compared this location to the location found in the Project Navigator by right clicking on the file name there and selecting "Show in Finder".然后,我通过右键单击那里的文件名并选择“在 Finder 中显示”,将此位置与在项目导航器中找到的位置进行比较。

The problem for me was that I had added the project file instead of the project folder in Xcode.我的问题是我在 Xcode 中添加了项目文件而不是项目文件夹。 I recommend closing the window, opening another instance of Xcode with the FOLDER that contains the project in it instead.我建议关闭窗口,用包含项目的文件夹打开另一个 Xcode 实例。

This is usually caused by the clock icon as mentioned by @jonthornham.这通常是由@jonthornham 提到的时钟图标引起的。 For a detailed explanation, please visit this site: https://xalting.com/2019/12/26/what-to-do-if-your-files-are-not-showing-up-in-xcode/ .有关详细说明,请访问此站点: https : //xalting.com/2019/12/26/what-to-do-if-your-files-are-not-showing-up-in-xcode/

This is caused by conflicts project.pbxproj file inside your projects, to get out of this error just follow bellow steps.这是由项目中的 project.pbxproj 文件冲突引起的,要摆脱此错误,只需按照以下步骤操作即可。

  1. Find the backup of your project, if you don't have any backup copy "project.pbxproj" file from another (any) project.如果您没有来自另一个(任何)项目的任何备份副本“project.pbxproj”文件,请找到您项目的备份。 its located inside "projectName.xcodeproj" just copy it by clicking show package contents.它位于“projectName.xcodeproj”内,只需单击“显示包内容”即可复制它。
  2. Replace this file in your current project.在您当前的项目中替换此文件。

Thats it!就是这样!

Happy Coding快乐编码

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM