You'd need to emulate macOS hardware, not iOS, to do that. In that sense, what you describe is already possible (running Xcode in a macOS VM on commodity hardware).

I did this exact think back in 2012 with a PhoneGap/Apache Cordova app. It had to use Xcode to run the app in the iOS Emulator. So I spun up a virtual machine on my Linux box. It worked extraordinarily well!

In the case of the poster you are replying to. Yes, Swift is open source and there are compilers for other platforms. The problem comes in with Apple's SDK and their proprietary libraries. Those are what are required to build an app that'll run on an iOS device. Those only run on macOS/OSX.

These days, unfortunately, it is not possible. Well, you can virtualize MacOs, but you can not connect iOS device to it, nor you can run a virtual iOS device inside it.

Apple went out of its way to deliberately disable physical phones connecting to a virtual MacOS. Any other USB device can be connected, but not an iphone.

I use this: https://github.com/kholia/OSX-KVM

It works quite well for me. Simulator works fine (though graphics are slow) and so does connecting a physical phone (by passing through the USB controller).