Is it possible to use an #ifdef to distinquish between platform versions

You can add a small extra-script that will inject the package versions as macros into the build system, which your code can then check against. See Injection of version of the computed libraries - #4 by maxgerhardt

I was wrong. If you include Arduino.h you also get the information from this file

So you can check the Arduino core version macros, which are very likely the cause of the build failure.

Are you hower sure you don’t want to enforce platform = espressif32@3.2.0 so that everyone 100% guaranteed builds on the same basis? (Arduino core, platform code etc.)