Debug an infinite (Swift) build in Xcode

I refactored some code to remove some duplication using generics, several protocols + protocol extensions.

Since then, my build doesn't seem to finish anymore. What used to take 10-20 minutes for a full-build now doesn't seem to finish anymore even after 2 hours. At some point Xcode's process gets stuck at something like "1837 of 2345 tasks". I verified that one of my changes is responsible by switching back to the master branch which still builds fine.

I sadly can't post the code here, both because the project is too big and because it's closed source. What I'm looking for is some hints/ideas how to debug this and figure out:

  • At which file Swift gets stuck.
  • What's the error it can't resolve so I can change that bit of code

So far I've looked at the build log in Xcode's report navigator, which allows me to see which files were successfully compiled (assuming that a green checkmark means "compiled"). I can also see a large set of files with a gray arrow in front (not yet a green checkmark), but there are many of those (> 100) so it's hard to see which one causes Swift issues. So instead I'd like to see which ones Swift is actively compiling right now, and ideally, which one it has been compiling for a long time already. Is something like this possible or is there a better way to find the offending code?

I've had this kind of thing with generics. The only way around that I have found is to carefully trace every generic parameter and its constraints to find the recursion.

You might find that old fashioned idea of a pencil and paper to draw a map of them useful :sunglasses:

It's neither easy nor obvious :roll_eyes::crazy_face::wink: