error: Unable to resolve build file: XCBCore.BuildFile (namedReferencesCannotBeResolved) (in target 'Project_Target')

I get the below error quite freqently on my IDE


error: Unable to resolve build file: XCBCore.BuildFile (namedReferencesCannotBeResolved) (in target 'project_name')


And often there is no way to recover from this error. We are using Carthage to pull the dependencies.

I have cleaned derived data, cleaned carthage cache, cleaned xcode.Closed xcode project, Quit XCode.


I have looked through various stackoverflow answers as well. and this error has been random in nature. it started with xcode 10.2.

It sometimes disappears after xcode restarts, sometimes you have to do a machine restart.


There was once while debuging i got issue with swift.



swift -version

Segmentation fault 1:1


It would really help if apple can provide some guidance on this issue.

Following is one the build outputs




Showing All Messages



Prepare build

note: Using new build systemnote: Planning buildnote: Using build description from memory



Build system information

error: Unable to resolve build file: XCBCore.BuildFile (namedReferencesCannotBeResolved) (in target 'project_target')





Build failed 8/31/19, 11:46 AM 0.9 seconds

Hey,


1. Go to the menu Xcode -> Preferences and select the locations tab

2. Click the little arrow next to 'Derived Data' to open it in Finder.

3. Quit xcode

4.You will see a bunch of folder in the DerivedData, delete all of them.

5. Restart Xcode and build your project.


Following above steps resolved the issue for me.

error: Unable to resolve build file: XCBCore.BuildFile (namedReferencesCannotBeResolved) (in target 'Project_Target')
 
 
Q