Advice on adding macOS support to a Windows program

I've written a chess program for Windows in C++, and am interested in porting it to macOS. I have a variety of questions on how to go about this. I'll start with the question of how to set up the project.

My intention, roughly speaking, is to have a directory of all the Windows-specific code, one of just macOS-specific code, and one of the C++ back end that both operating systems will call into. If possible, I would like to keep all this code in a single project, selecting the desired front end code with pound defines and tracking it with a single Git repository, since the parts don't mean much one their own. Is there a way to do this that would play nicely with Git and the built-in Git support of Xcode and Visual Studio, respectively? At least with default settings, Visual Studio's Git support uploads the entire solution, which is to say, my code wrapped in and interspersed with a bunch of auto-generated IDE-specific stuff. I assume I couldn't simply import that whole mess into Xcode, where I'd end up with source wrapped in Visual studio stuff wrapped in Xcode stuff. Is using multiple repositories the way this is always done?

1 Like

Generally it makes a lot of sense to split the code into a platform-agnostic core module and two frontends.

I don’t know what the usual way of distributing C++ code is, but if this were a C library, I would create one separately versioned repo with the library and then two repos with GUI frontends. The frontend projects would then import the “core” using the usual tools in the IDE.

That way you would get good separation of concerns and the platform-specific frontends wouldn’t have to know anything about the others. The downside is that if you often change things across the whole stack, you would have to introduce the changes into the core library, then update the dependency in the frontend and make changes in the GUI. If this sounds too cumbersome, you may use a single repo for all three modules, allowing you to make atomic changes to all three of them with a single commit.

PS. This forum is more about the Swift language itself and less about the toolchains such as Xcode. You may have more success asking somewhere more general, such as Stack Overflow.

1 Like