Seems you're doing it the right way. Xcode doesn't cross-compile for non-Apple platforms, nor does it run within a Linux environment. Most everyone uses a Linux virtual machine or Docker image to compile and run code on Linux using a MacOS host computer. Multipass is one such virtual machine environment. Not really an emulation since the basic instruction set is the same.
Since Multipass is a command line tool under Darwin, conceivably you could build an Xcode run script that runs a series of commands to Multipass, or add an external Makefile target to build the Ubuntu image using Multipass-based commands from within Xcode, but, you just using Xcode as a way to run the Makefile. But, it could work, build and debug on Darwin, build the Ubuntu Makefile target, and, if you want, add another Makefile target to run a test script using the Ubuntu image