Swift Build Failure: Target May Include Own Product

Has anyone encountered this problem? I experimented with porting an existing obj-c application to Swift, and after several successful builds, the project will no longer build and will immediately throw an error: the command "CompileSwift normal" could not be launched - this goal may include its own product. Along with many other “targets,” there may be product errors.

What I tried:

  • Checking dependencies between objects: in the assembly phases, nothing is specified as a target dependency.
  • I tried to completely delete the product folders and looked through all the files many times, but with no luck.
  • If I just replace Swift files with old obj-c files, it builds fine, no errors at all.
  • Restoring to a snapshot before any Swift changes results in the creation as usual, but even if I add a new Swift template file and the bridge title, and then click Create, it does not have the same errors.
+6
source share
3 answers

I had the same problem. I couldn’t determine exactly what exactly caused this, but I realized that the same code would build find on a different Xcode 6 installation on a different machine.

I solved it by deleting my cached assemblies, etc. in ~/Library/Developer/Xcode , and Xcode is not running. "Clean" from within Xcode did not.

You should find that when you restart Xcode, your application will work fine.

+11
source

Removing my application target from “Assembling phases → Copying package resources” worked for me. (Somehow he was included in the package?)

+3
source

I could reproduce the problem. In the objc-to-swift header, I imported the objc class header, which also imports the swift-to-objc header. There was an import loop, and this could be the cause of the Xcode complaint.

I think at the moment it is better to avoid such a cyclic import between fast and objc. You can check it out.

0
source

Source: https://habr.com/ru/post/970420/


All Articles