Modify a library for a specific sketch only

When you put library files in the sketch folder they are all shown as tabs in the Arduino IDE. This may be desirable since it allows you to view and modify the library source. However, it also clutters up the Arduino IDE if you only want to work on the sketch and if you do this with multiple libraries the sketch folder will get very messy. Also, that won't work with libraries that have source files in separate subfolders.

Another option is to put the libraries under the src subfolder of the sketch folder. For example, say you have a sketch named foosketch and a library named foolib, the folder structure would look like this:

foosketch
|_foosketch.ino
|_src
|_foolib
|_foolib.h

Include in the sketch like this:

#include "src/foolib/foolib.h"

Note this usage is only supported in recent versions of the Arduino IDE.

When you put libraries in the sketch folder, whether in the root or src subfolder, you will encounter a compilation error if any of the library files use the #include <foo.h> syntax to include internal library files. Although incorrect, this works when the library is located in a standard library folder so it's a common problem. The solution is to simply modify the library source to use the #include "foo.h" syntax.