I'm getting “clang: error: no input files”

2019-01-23 10:41发布

问题:

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?

回答1:

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!

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.



回答2:

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



回答3:

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.



回答4:

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



回答5:

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.



回答6:

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

use_frameworks!


回答7:

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.



回答8:

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.



标签: xcode clang