During my internship I worked a lot with the Unity game engine. When using Unity you have the possibility to create games for a whole lot of different platforms, ranging from mobile phones to game consoles and everything in between.
Why?
Why did I need to use cross-platform compilation? Well… CP Social had to support features that had their own specific implementations on every supported platform.
So the be able to add these functionalities I had to be able to separate the logic for each platform specific implementation.
How?
Unity has things called ‘Assembly definitions‘ and ‘pre-processor directives‘ these things allow you to tell Unity what it should compile and what it has to leave behind when building your game for a specific target platform.
By using these features in a smart way it’s possible to switch out entire systems for one another when building for a specific target platform, which in turn gives you a completely different implementation for a feature.
For a more detailed explanation how these ‘Assembly definitions‘ and ‘pre-processor directives‘ are used in practice you can take a look at Steam Vs Unsupported.
Conclusion
By making use of ‘Assembly definitions‘ and ‘pre-processor directives‘ I was able to completely separate feature implementations per platform and make sure that only the required implementations would be included in a final build.