Xcode Error build: Build input file cannot be found

Error while building SwiftUI project:

error build: Build input file cannot be found: '/Did you forget to declare 
this file as an output of a script phase or custom build rule which produces it?

The solution is to go to Finder and manually drag that file (which is giving the error) into the desired folder and then the Xcode will prompt a message to add that file reference in the project.

Build the prject again and the issue will be fixed.