Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swift build fails: target might include it's own product

Tags:

swift

cocoa

Has anyone run into this issue? I was experimenting with porting an existing obj-c app to Swift, and after quite a few successful builds the project will no longer build and immediately gives the error: Unable to run command 'CompileSwift normal' - this target might include its own product. Along with many other 'target might include it's own product errors'.

What I've Tried:

  • Checking Target Dependencies: There is nothing listed as a target dependency in Build Phases.
  • I've tried completely deleting the product folders, and have went through all the files multiple times but with no luck.
  • If I simply replace the Swift files with the old obj-c files it builds fine, no errors at all.
  • Restoring to a snapshot prior to any Swift modifications results in building as normal, but even if I add a brand new Swift boilerplate file and bridging header, then click build, it fails with the same errors.
like image 436
tjames Avatar asked Jun 06 '14 01:06

tjames


2 Answers

I had the same issue. I couldn't work out exactly what was causing it, but realised the same code would build find on a different Xcode 6 install on a different machine.

I solved it by deleting my cached builds, etc, in ~/Library/Developer/Xcode, while Xcode is not running. "Clean" alone from within Xcode didn't do it.

You should find that when you re-launch Xcode your app will build fine.

like image 174
alistair Avatar answered Jan 03 '23 20:01

alistair


Deleting my app target from "Build Phases -> Copy Bundle Resources" worked for me. (Somehow it was being included for bundling?)

like image 23
Pup Avatar answered Jan 03 '23 20:01

Pup