What's the Xcode "no such file or directory error"?

Xcode

Xcode Problem Overview


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?

[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:

error: /Users/Me/Development/MyProject/MyIcons/../13-bicycle.png: No such file or directory

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).

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.

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.

I haven't even found a workaround beyond deleting the icons yet - cleaning doesn't work. I think my group is corrupted.

Xcode Solutions


Solution 1 - Xcode

look up here XCode Build – CopyPNGFile Error and No Such File or Directory . I had same problem and this solution helps me.

> If you receive either of these annoying errors when building your > xcode app, something has corrupted in your project bundle. > > 1. Open your project in Xcode > 2. Click on your project > 3. Click on your project under Targets > 4. Hit the build phases tab > 5. Open “Copy Bundle Resources” near the bottom > 6. Look for any resources listed in red!

Solution 2 - Xcode

I had the same problem but my solution was a bit different:

  1. Open project in Xcode
  2. Open project navigator
  3. In the filter down below, search for your erroneous file name
  4. I found the file under a group called "Recovered References" and it was marked in red
  5. Delete the red files and everything should work perfectly

Solution 3 - Xcode

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 except that Open in External Editor was greyed - weird eh?)

  1. I closed XCode and restarted it.

    => Now I see all of the icons under the offending group are red (in the Project Navigator)

  2. Delete the entire group.

  3. 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,

  4. I deleted all other groups with icons and moved their icons to trash

  5. open finder at the project location

  6. delete every icon in the project (sort by kind, delete all the .png)

  7. make a new group again, and drag all the icons in _again.

  8. whew, now hit Builder

    => XCode crashes.

    Lovely.

  9. Restart Xcode

  10. fingers crossed: Build

=> it works. Brief celebration and back to work.

(See what I mean about unsatisfactory)

Solution 4 - Xcode

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”

Solution 5 - Xcode

Check your project file paths. If there is a space in any of the folders, it causes this error. Simply remove spaces.

Solution 6 - Xcode

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.

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 needed checked.

Hope that helps someone.

HappyCoding

Solution 7 - Xcode

try set target CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS=NO

Solution 8 - Xcode

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.

  1. Open your project in Xcode
  2. Click on your project
  3. Click on your project under Targets
  4. Hit the build phases tab
  5. Open “Copy Bundle Resources” near the bottom
  6. Look for any resources listed in red!

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionzumzumView Question on Stackoverflow
Solution 1 - XcodeJuliaView Answer on Stackoverflow
Solution 2 - XcodeAly YakanView Answer on Stackoverflow
Solution 3 - XcodeRhubarbView Answer on Stackoverflow
Solution 4 - XcodeChenYilongView Answer on Stackoverflow
Solution 5 - XcodeyigitserinView Answer on Stackoverflow
Solution 6 - XcodeBaraka MahiliView Answer on Stackoverflow
Solution 7 - XcodeSlemanView Answer on Stackoverflow
Solution 8 - XcodeShangkai LiView Answer on Stackoverflow