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.
VmWare Player with USB configured to version 2.0 did the trick for me. I tested it with an iPAD Pro and iOS 14. The VM was running the newest macOS release from a few months ago.
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).
I'd like to chime in here that it's very fucking frustrating that the best & most convenient free tools for virtualizing macOS aren't available on macOS, considering macOS has shipped with a damn hypervisor for years. Setting up a vanilla installation of arbitrary, older version of macOS for testing, or for maintaining build environments for long-support-life Mac software, should be one command, shipped with the dev tools. But no, instead it's "pay for a 3rd party solution" or "break the EULA and run it on Linux".
(yes, I'm aware of a bunch of fragile solutions involving VirtualBox, but they tend to be slowish, that's also supposed to be paid if you're using the extensions for commercial operation IIRC, and several versions of macOS/OSX remain a huge pain in the ass to set up on it regardless)
a motivated individual can still accomplish it, there are multiple ways documented on the web if you google a little.
its however not permissable, as you cannot buy apple software without agreeing to their licence, which disallows running it on anything but apple hardware.
There's no difference in the binaries built by Xcode running directly on Apple-branded hardware and Xcode running in a macOS VM in a generic (or perhaps metal, if nested virtualization isn't available) ec2 instance.
Well, may be I am unlucky one, but I just tried and freshly installed MacOS in VirtualBox VM can see any other USB device except iPhone XR.
This setup used to work find a few years ago but stopped a at least on 2018.
Will try VMWare.
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.