Similar to some other answers, but this is much easier:
open a finder window,
type the app name into the search box, and
delete all the files that show up. (Sometimes under Debug folder, Release folder, and/or codesign folder)
try reinstall the app using the pkg file.