Or, in other words, do what any third-party app developer who ships apps for iOS+macOS from a single XCode project source does—but build your whole OS like that.
As well, ideally, the view layer would be modular enough that it could be unloaded and reloaded at runtime, such that you'd be able to dock your phone to an external display and have all your running applications switch to their desktop UI view-layers without losing state.