After days of having a similar problem as yours, I did the following:
Follow this StackOverflow answer
Completely close all terminals & close XCode
Reopen XCode to successfully start compiling & archiving iOS builds 🚀
Topic:
Developer Tools & Services
SubTopic:
Xcode
Tags: