Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Incorrect object in root directory of Xcode project

Tags:

xcode

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/path-here-to-controller.swift'

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:

Please find attached image

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.


2 Answers

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)

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.

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.

enter image description here

like image 149
Arc676 Avatar answered Nov 24 '25 08:11

Arc676


Go Xcode->File->Add Files... and add missing files to the project.

like image 28
Janusz Chudzynski Avatar answered Nov 24 '25 07:11

Janusz Chudzynski



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!