Lib depending on a particular platform/framework version

I have a library I wrote for my Teensy 3.x projects that relies on a function delayNanoseconds() that is only present in platform-teensy release 4.13.0 and newer releases including at least Teensyduino v1.54.

Is it possible to declare a dependency in library.json on a particular framework version?

No, not that I know of.

Either you have to request that in the core (Issues · platformio/platformio-core · GitHub) or find a way around in code – there may be macros in the Teensy core telling you its release version, based on which you can at least throw a nicer error message.

Hi Max, thank you for the clarification, that’s what I suspected too. What I thought initially was that maybe having a framework version requirement for a library would force PIO to update the consumer project’s framework as needed, but in hindsight it doesn’t seem hierarchically right for a library to trigger an update of a parent project’s framework.

I believe your approach of throwing a compilation error would be the best compromise here, the compilation would fail anyway if the framework version is lower than what’s expected but I can make it fail gracefully by checking the TEENSYDUINO #define value.