Xcode“没有这样的文件或目录错误”是什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10167442/
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 Xcode "no such file or directory error"?
提问by zumzum
Xcode keeps prompting telling me I don't have a certain image in the project and it errors when I try to build. If I deleted the .png Xcode is complaining about from the project, why does Xcode error out when I try to build?
Xcode 不断提示告诉我我在项目中没有特定的图像,并且在我尝试构建时出错。如果我从项目中删除了 Xcode 抱怨的 .png,为什么在我尝试构建时 Xcode 会出错?
[Edited by Rhubarb (got too big for the comments)]
[由大黄编辑(评论太大了)]
I'm getting the same thing with these details. The copy command looks like this
我对这些细节也有同样的看法。复制命令看起来像这样
CpResource MyIcons/../13-bicycle.png /Users/Me/Library/Developer/Xcode/DerivedData/MyProject-cxsohyxdecdbptgrrtaixbhhixrj/Build/Products/Debug-iphonesimulator/MyProject.app/13-bicycle.png
then there's a bunch of setenv and the command is translated to "builtin-copy" but none of that matters, the result is when I compile I get this error:
然后有一堆 setenv 并且命令被翻译成“builtin-copy”,但这些都不重要,结果是当我编译时出现这个错误:
error: /Users/Me/Development/MyProject/MyIcons/../13-bicycle.png: No such file or directory
错误:/Users/Me/Development/MyProject/MyIcons/../13-bicycle.png:没有那个文件或目录
Now, I opened the Copy Bundle Resources tab as suggested by Robert Harvey, and my .png is there, with nothing appearing in read. And it is in the file system (Finder) and in the Project Navigator. So I deleted it from the resources using the - button and added it manually using the + button at the bottom left of the list in the Copy Bundle Resources tab. This put it at the root of the project in the Navigator, so I moved it into my group again - but no luck, same error. So I just deleted it altogether (from the Project Navigator, allowing it to be moved to Trash). That worked, but I ran into the same error with the very next icon (it only reports one or two at a time).
现在,我按照 Robert Harvey 的建议打开了 Copy Bundle Resources 选项卡,我的 .png 就在那里,没有任何内容出现在读取中。它位于文件系统 (Finder) 和项目导航器中。因此,我使用 - 按钮将其从资源中删除,并使用 Copy Bundle Resources 选项卡中列表左下方的 + 按钮手动添加它。这将它放在导航器中项目的根目录,所以我再次将它移到我的组中 - 但没有运气,同样的错误。所以我只是完全删除了它(从项目导航器中,允许将其移至废纸篓)。那行得通,但我在下一个图标上遇到了同样的错误(一次只报告一两个)。
Looking at the error message, it appears to think that MyIcons is a folder. It's not, it's just a group. There is no such folder, I can see in the file system.
查看错误消息,似乎认为 MyIcons 是一个文件夹。不是,这只是一个群体。没有这样的文件夹,我可以在文件系统中看到。
When I added via drag-drop, I left the "Copy items into ... group folder (if needed)" checked and the "Create groups for any added folders" button selected. But note that I only dragged icons (en masse) into an existing group; I did not drag over any folders, nor where any groups or folders created. But somehow, the compiler thinks that these resources are in a folder in the file system that doesn't exist.
当我通过拖放添加时,我选中了“将项目复制到...组文件夹(如果需要)”并选中了“为任何添加的文件夹创建组”按钮。但请注意,我只将图标(整体)拖到现有组中;我没有拖过任何文件夹,也没有拖过任何创建的组或文件夹。但是不知何故,编译器认为这些资源位于文件系统中不存在的文件夹中。
I right clicked the icon in the Copy Resources List and tried both Show in Finder and Reveal in Project Navigator: and both worked - the file is there and it knows where to get it - until it builds.
我右键单击复制资源列表中的图标,并尝试在 Finder 中显示和在项目导航器中显示:两者都有效 - 文件在那里并且它知道从哪里获取它 - 直到它构建。
I haven't even found a workaround beyond deleting the icons yet - cleaning doesn't work. I think my group is corrupted.
我什至还没有找到除删除图标之外的解决方法 - 清洁不起作用。我认为我的组已损坏。
回答by Julia
look up here XCode Build – CopyPNGFile Error and No Such File or Directory. I had same problem and this solution helps me.
在这里查找XCode Build – CopyPNGFile Error and No such File or Directory。我有同样的问题,这个解决方案对我有帮助。
If you receive either of these annoying errors when building your xcode app, something has corrupted in your project bundle.
- Open your project in Xcode
- Click on your project
- Click on your project under Targets
- Hit the build phases tab
- Open “Copy Bundle Resources” near the bottom
- Look for any resources listed in red!
如果您在构建 xcode 应用程序时收到这些烦人的错误中的任何一个,则说明您的项目包中的某些内容已损坏。
- 在 Xcode 中打开您的项目
- 点击你的项目
- 在目标下单击您的项目
- 点击构建阶段选项卡
- 打开底部附近的“复制捆绑资源”
- 寻找红色列出的任何资源!
回答by Aly Yakan
I had the same problem but my solution was a bit different:
我有同样的问题,但我的解决方案有点不同:
- Open project in Xcode
- Open project navigator
- In the filter down below, search for your erroneous file name
- I found the file under a group called "Recovered References" and it was marked in red
- Delete the red files and everything should work perfectly
- 在 Xcode 中打开项目
- 打开项目导航器
- 在下面的过滤器中,搜索您错误的文件名
- 我在一个名为“Recovered References”的组下找到了该文件,它被标记为红色
- 删除红色文件,一切正常
回答by Rhubarb
Okay here's the unsatisfactory workaround that fixed it for me.
好的,这是为我修复的不令人满意的解决方法。
(First, note that when I right-clicked my dodgy Group in the Project Navigator) it looked like any other group exceptthat Open in External Editor was greyed - weird eh?)
(首先,请注意,当我在项目导航器中右键单击我狡猾的组时)它看起来像任何其他组,除了在外部编辑器中打开是灰色的 - 很奇怪吗?)
I closed XCode and restarted it.
=> Now I see all of the icons under the offending group are red (in the Project Navigator)
Delete the entire group.
Create a new group (same name) and drag-drop the icons from the original source into the group
=> Error failed to copy (or some such - I can't remember but I have seen and fixed this before - and seen it elsewhere on SO)
This error is due to leftover icons, so to fix this one now,
I deleted all other groups with icons and moved their icons to trash
- open finder at the project location
- delete every icon in the project (sort by kind, delete all the .png)
make a new group again, and drag all the icons in _again.
whew, now hit Builder
=> XCode crashes.
Lovely.
Restart Xcode
- fingers crossed: Build
我关闭了 XCode 并重新启动它。
=> 现在我看到违规组下的所有图标都是红色的(在项目导航器中)
删除整个组。
创建一个新组(同名)并将图标从原始源拖放到组中
=> 错误无法复制(或一些类似的 - 我不记得了,但我以前看过并修复过这个 - 并在 SO 的其他地方看到过)
这个错误是由于剩余的图标造成的,所以现在要解决这个问题,
我删除了所有其他带有图标的组并将它们的图标移到垃圾箱
- 在项目位置打开finder
- 删除项目中的每个图标(按种类排序,删除所有 .png)
再次创建一个新组,并拖动_again中的所有图标。
哇,现在点击生成器
=> XCode 崩溃。
迷人的。
重启Xcode
- 手指交叉:构建
=> it works. Brief celebration and back to work.
=> 它有效。简短的庆祝活动并返回工作岗位。
(See what I mean about unsatisfactory)
(看看我说的不满意是什么意思)
回答by ElonChan
perhaps you move the file named **-Prefix.pch,you can change the dictionary of the file ,do like this : the error about “no such file or directory”
也许你移动了名为**-Prefix.pch的文件,你可以改变文件的字典,这样做:关于“没有这样的文件或目录”的错误
回答by yigitserin
Check your project file paths. If there is a space in any of the folders, it causes this error. Simply remove spaces.
检查您的项目文件路径。如果任何文件夹中有空格,则会导致此错误。只需删除空格。
回答by Baraka Mahili
Using XCode 10, I got this error after deleting some files I no longer needed in my project. In my case, I went to XCode, clicked on the project name, then under Resources, the missing files were listed in red. All I did was to delete them.
使用 XCode 10,我在删除了项目中不再需要的一些文件后出现此错误。就我而言,我转到 XCode,单击项目名称,然后在Resources下,丢失的文件以红色列出。我所做的就是删除它们。
In case you need the files, you will need to add them by going to File ->Add files to , then select the files. After selecting the file, make sure you have Copy files if neededchecked.
如果您需要这些文件,您需要通过转到 File ->Add files to 来添加它们,然后选择文件。选择文件后,确保选中了需要时复制文件。
Hope that helps someone.
希望能帮助某人。
HappyCoding
快乐编码
回答by Sleman
try set target CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS=NO
尝试设置目标 CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS=NO
回答by Shangkai Li
XCode Build – CopyPNGFile Error and No Such File or Directory
XCode 构建 – CopyPNGFile 错误并且没有这样的文件或目录
If you receive either of these annoying errors when building your xcode app, something has corrupted in your project bundle.
如果您在构建 xcode 应用程序时收到这些烦人的错误中的任何一个,则说明您的项目包中的某些内容已损坏。
- Open your project in Xcode
- Click on your project
- Click on your project under Targets
- Hit the build phases tab
- Open “Copy Bundle Resources” near the bottom
- Look for any resources listed in red!
- 在 Xcode 中打开您的项目
- 点击你的项目
- 在目标下单击您的项目
- 点击构建阶段选项卡
- 打开底部附近的“复制捆绑资源”
- 寻找红色列出的任何资源!