错误:没有那个文件或目录 [英] Error: no such file or directory

查看:36
本文介绍了错误:没有那个文件或目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的项目运行良好.然后我将一些文件从项目的根目录移动到一些子文件夹.现在,当我尝试运行该应用程序时,收到此错误消息:

My project was working perfectly fine. I then moved some files around from the project's root directory to some subfolders. Now, when I try to run the app, I receive this error message:

<unknown>:0: error: no such file or directory: 
'/Users/anapaix/Desktop/currencyExchange/CommentsController.swift'

我移动的所有 20 个文件都收到同样的错误.

And I receive this same error for all 20 of the files that I moved around.

此外,文件现在在我的项目中显示为红色:

Additionally, the files now show up in red like this in my project:

当我双击文件时,会出现一个空的 Swift 文件,就像里面什么都没有.我觉得应该有一些简单的解决方法,以便 Xcode 识别这些文件,但不知道它会是什么.

When I double click the file, an empty Swift file shows up, like there is nothing inside. I have a feeling there should be some easy fix to this, in order for Xcode to recognize these files, but just have no idea what it would be.

推荐答案

您移动了文件.Xcode 不知道.您需要告诉 Xcode 文件在哪里.(注意:其他答案也适用,但如果您不想删除它们并再次添加它们,则可以使用此方法)

You moved the files. Xcode doesn't know that. You need to tell Xcode where the files are. (Note: the other answers work too, but if you don't want to remove them and add them again, you can use this method)

选择您的红色文件,打开文件检查器(Option+Command+1),然后单击文件夹(在下面的屏幕截图中以红色圈出).然后找到您的文件并点击Choose.文件名应该恢复为黑色.

Select your red file(s), open the File Inspector (Option+Command+1), and click the folder (circled in red in the below screenshot). Then find your file(s) and click Choose. The filenames should go back to being black.

如果同一个文件夹中有多个红色文件,可以在Project Navigator(左栏,Command+1)中选择多个文件,点击File Inspector中的文件夹图标(仍然是红色圈出的那个,但是文本会有所不同;它可能会说多选"或其他内容)并单击包含文件的文件夹.Xcode 应该会自动检测所有这些文件,前提是文件名没有改变.

If multiple red files are in the same folder, you can select multiple files in the Project Navigator (left column, Command+1), click the folder icon in the File Inspector (still the one circled in red, but the text will be different; it might say "multiple selected" or something) and click the folder containing the files. Xcode should automatically detect all of them, provided the filenames haven't changed.

这篇关于错误:没有那个文件或目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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