tjames tjames - 4 years ago 180
Swift Question

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

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.


Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download