39
votes

I had a file which I deleted and replaced with another file, somewhere else, of the same name.

Despite cleaning, and trying this multiple times, I keep getting this error:

clang: error: no such file or directory: '/Users/Andrew/App/Version 1.1/XCode/UIImage+Alpha.m' clang: error: no input files

I can't continue working on my app because of it. Any ideas?

10
when you deleted the file, did you just delete it in Finder, or did you delete the reference to that file in your Xcode project? Check for a leftover reference in the project navigator, or on a target's list of files in the project editor.bames53

10 Answers

103
votes

The problem might be because your project > target > Build Phases > Compile Sources is trying to compile a file that doesn't exist. It might be in there twice, like the below screen shot. My project contains UIImage+FFXtras, I can even remove it and re-add it and this won't resolve the problem!

missing source file

I'm not sure how the project gets into this state - but I know it's not obvious what is going wrong. Highlight the red problem one and remove it.

So have a look in compile sources phase for the file clang is complaining about.

6
votes

Got the similar troubles.

It seems XCode does not generate correct relative filepath when your project refer to an already existing source tree (relative path does not contain the .xcodeproj in the path of the file to be compiled).

There is a simple fix however: in the project explorer select the file or files files then look at the options in the file inspector. One of them is labeled "Location"; set it to absolut path and try again. This fixed the issue for me :)

enter image description here

4
votes

Additional to all answers:

  1. delete derived data
  2. reboot
  3. delete derived data
  4. clean
  5. build
  6. Success!

Only this sequence works for me in my case.

2
votes

I use quite a few cocoa pods and have just had this happen to me. A quick "pods update" sorted things out for me. -phil

1
votes

If you are using vs code and facing this issue which says

clang: error: no such file or directory: 'filename'
clang: error: no input files

Error while running files:

error while running files

I solved this issue by removing the space or replacing the space with underscore(_) in the filename .extension

0
votes

In case everything fails (i.e. first try bames53 suggestion)

Ok, this might be dangerous so make a copy of your whole project first:

  • close Xcode
  • locate the project file in the Finder
  • right click, choose "show package contents"
  • open project.pbxproj in a text editor of your choice, but not Xcode
  • search for your file
    • at the beginning of the line that shows up, you'll see some id like 640450991409CF5C00B3B580. Search for this and delete any line you find.
    • pay attention, not to break the syntax (balance parenthesis and brackets, pay attention for commas)
  • when you are done, save the file and try to open the project in Xcode. Add the missing file via the Add file… dialog of Xcode. It is still in the folder of your project — if you added it successfully in the first place — you just got rid of all project references.
  • dont be surprised, if it doesnt work instantly — you have a copy. copy it again, new try.

And remember: make a copy of your whole project first — for every try. or copying the project.pbxproj might be enough.

0
votes

Add this line in your pod-file and run pod install:

use_frameworks!
0
votes

I had this error in monodevelop. I just went to edit>preferences and changed the default location of the program files. It was set to the monodevelop default they give you when you open a file and not the folder i changed it too. Likely, you need to adjust the settings of xcode, where you stored your files.

0
votes

I was seeing this while setting up a React Native project. Solved it using:

sudo xcode-select --switch /Applications/Xcode.app

Source

-1
votes

Comment Quoted from another site was the issue is resolved for me

hmm that's strange. Try this - click on the name of your project on the list of files/folders on the left in Xcode (at the very top of the list). Look at the "Targets" section on the left-hand side of the window to the right. Likely, there's two listed with the second being a "test" item. Right-click on that item and select "delete". Then try to run the project again. See screenshot below for a visual cue.