Several example sketches fail

The "Arduino Mbed OS Nano Boards" platform provides support for the Nordic nRF52840-based Nano 33 BLE boards and the Raspberry Pi RP2040-based Nano RP2040 Connect.

And if you look at the "Arduino Mbed OS Boards" platform as a whole, the diversity of targets is even more diverse.

The same applies to the new Zephyr OS-based platform.

The "Teensy" platform supports the modern NXP-based boards as well as the older AVR-based boards.

Even though the "esp32" platform only supports microcontrollers of the "ESP32" family, there are actually very significant differences between the targets, to the point of even needing different toolchains.

Not in this context where we are talking about Arduino IDE populating the File > Examples menu.

In my previous reply, I mentioned that there is a proposal for allowing library compatibility to be specified via the library metadata to a board-level granularity. But there isn't anything like that currently.

Note that Arduino IDE doesn't have any understanding of the core, library, and sketch code when populating the menu. It only has the information provided by the platform configuration and library metadata.

Well, boards.txt defines a unique machine identifier for the board. This is probably all that is needed from the platform. That identifier can then be used in compatibility/incompatibility lists in the library metadata.

Of course, you could go further by taking the approach of instead defining arbitrary attributes of the board (e.g., wifi-s3, hid) in the platform's board definition and then specifying the required attributes in sketch metadata. However, this would be more difficult to implement since it requires coordination between the platform and sketch developers, whereas the current proposal doesn't require any work in the platforms.