some exciting news for arduino library writers and maintainers - there has been some activity over at the arduino ide github repo to add the beginnings of a library dependency manager!
check out the merged PR here:
this is what the new IDE will look like... attached.
try downloading the preliminary builds to test out this awesome new capability, they're auto built and ready to try!
we'll be adding this capability to our hundreds of libraries soon!
For anyone wanting to define dependencies of their libraries, the field name mentioned in the pull request description is incorrect. The library.properties field is called depends, not requires.
I think it's still not implemented in the Arduino IDE, but plans are to also allow you to specify dependencies versions, as explained by the author of the feature:
there is the possibility to add a version constraint in this way:
depends=First Library (=2.0.0), Second Library (>=1.2.0), Third (^1.2.3)
BTW these constraints are implemented on the indexer (so they are reported on the library_index.json) but not yet in the IDE (it will always install the latest version). The constraints supported are the classic > >= = etc. and the special ^ (that means "compatible with").
Here you can see the feature in use in the Arduino_OAuth library:
This results in a dialog similar to that shown in adafruit's screenshot above when you install the Arduino_OAuth library via Library Manager.
I tried to include a fields "depends" on my library, and then load it with "Sketch / include Library / Add .ZIP library". But nothing happened. Simple a message "Library added to your libraries". The depended library was not installed.
They say in the FAQ that the library dependencies are currently ignored. Is the FAQ wrong?
Another question, is it possible to test this dependency mechanism without really publishing the library? I just want to test this mechanism without disturbing a developer...
cdupont:
They say in the FAQ that the library dependencies are currently ignored. Is the FAQ wrong?
Yes. That was outdated information. I have now fixed it. Thanks for pointing that out!
cdupont:
is it possible to test this dependency mechanism without really publishing the library?
I'm sure it's possible, but you would need to figure out how to trick the Arduino IDE into using a modified library_index.json file instead of downloading the official one from http://downloads.arduino.cc/libraries/library_index.json. I haven't ever done that so I can't give any specific advice. I remember that when Boards Manager (which uses a similar JSON system to Library Manager) was first released, before it had been opened up to 3rd party URLs, Adafruit figured out a hack using a proxy to allow you to install their hardware packages via Boards Manager: Overview | Adding Custom Boards to the Arduino v1.6.3 Board Manager | Adafruit Learning System
It's possible that approach could be adapted to point the IDE to a custom Library Manager JSON file. Maybe someone else here will have an idea of how to do this.
I also seem to remember that there is an undocumented feature of the IDE where a special filename in the Arduino15 folder causes the Arduino IDE to use a development version of the JSON file (something like boards_development_index.json). I know it was mentioned on the arduino/Arduino issue tracker on GitHub sometime years ago by one of the Arduino developers, but I can't find it now. I don't know whether the same feature also applies to the Library Manager JSON file.