PlatformIO Community

Platform-specific dependencies in library.json?


Could I have a clarification how platform-specific dependencies should be defined in library.json? Our component of our project (SensESP) needs to use software serial bus implementation (the EspSoftwareSerial library). We support both esp8266 and esp32. On esp8266 the library comes as part of the framework but on esp32 not. The library.json documentation is not very clear but I understand the “platforms” attribute should limit the platforms for the dependency. Hence, we have the following in our library.json:

  "name": "EspSoftwareSerial",
  "platforms": ["espressif32"]

That doesn’t work: a version of the library does always get pulled in also when building against the d1_mini environment, and the build fails. If that section is removed from library.json, the problem disappears.

How should we define our dependencies so that they work on both platforms?

Any insights on this?

Looks good to me according to if that is one subobject of the dependencies attribute.

Maybe @ivankravets can look at why it stills pulls and includes that dependency for an espressif8266 environment?

You’re also using the latest PIO core version? (CLI -> pio upgrade --dev -> VSCode restart)

1 Like

You need to change

1 Like