I got an Xcode error that says "Uncategorized Command CompileSwiftSources failed with a nonzero exit code". I notice that in the toolbar next to the name of my app it says "My Mac" and I can't switch it back to iPhone. Can this be causing the error? How do I fix it?
That "archive" contains only your built app, so you can't recover you project from it. If your project is corrupted, then you should get it back from:
— An earlier version of your source code repository, if you're using SCM (source code management) such as GitHub.
— A backed up version, from one of your regular backups (e.g. Time Machine).
If you're not using SCM, I strongly advise you start using it, since it's the easiest way to go back in time in a controlled manner. If you're not doing regular backups (whether or not you use SCM), you will almost certainly have a very, very bad experience one day soon, when you lose everything, not just an Xcode project. 🙂
If you don't have one of those options right now, you may have to recreate the Xcode project from scratch. (However, you shouldn't need to recreate the source files. You already have them, so create a new project and add them to it.)