Had this problem on a SwiftUI project. Turned out one of my SwiftUI views had an incorrectly declared variable. I had:
@EnvironmentObject var roomViewModel
where I needed:
@EnvironmentObject var roomViewModel: RoomViewModel
There was no compiler error, just endless indexing. After I fixed the error, the project built quickly.