How to develop or edit an Arduino library? I'm not sure if I should split this question in two.
I had to edit some libraries and I plan to make some myself but didn't try yet.

Editing a library seems very laborious comared to editing a sketch.

I have to use an external editor and then compile on the Arduino IDE with the help of a test sketch. 

I wish to use the Arduino IDE to edit the libraries but it seems it is not easy, maybe in future reales it is supported.

The libraries used to be on %home%/Arduino/libraries/etc. but now I have to edit some located at %appdata%\Arduino15\packages\esp8266\hardware\esp8266\1.6.5-947-g39819f0\libraries and it seems these packages might get updated so maybe it is not a good idea to edit them there but I am not sure.

What about GitHub and conflicts? I clone the library and edit it but then I have two versions and you can't choose one of them. So I have to delete the original from the arduino instalation or wherever it is to avoid the conflict.

I also wish to post the progress to GitHub and maybe receive collaboration there. Do you have any hint about the clone process or something to avoid any trouble with it?

And what about the .h/.o? Arduino precompile the headers on startup so if I edit a .h I have to find and delete the .o or restart the IDE.

How do you do all of this? Is there any trick that helps?

Thank you.
I'm not accepting any answer because they are only focused on versioning/git/github fork->edit->share and I am very interested on all the things that I have to do to make the development.




I will run through the basics of making a library. It's really quite simple, and they persist through upgrades to the IDE.

Let's imagine I have a useful function (or lots of functions) that I want to use in lots of sketches. For example, something that blinks an LED:

void blinkLED (const byte which, const int times)
  {
  for (int i = 0; i &lt; times; i++)
    {
    digitalWrite (which, HIGH);
    delay (500);
    digitalWrite (which, LOW);
    delay (500);
    }  // end of for loop
  } // end of blinkLED


And some test code:

void setup ()
  {
  Serial.begin (115200);
  Serial.println ();
  pinMode (13, OUTPUT);
  blinkLED (13, 5);
  }  // end of setup

void loop ()
  {
  }  // end of loop




Make a library

To turn that into a library we need three steps:


Make a folder for the library. This should be placed inside the libraries folder in your sketchbook folder. This folder:



In my case: /home/nick/sketchbook/libraries. It does not go into anywhere associated with the IDE download.


  but now I have to edit some located at %appdata%\Arduino15\packages\esp8266\hardware\esp8266\1.6.5-947-g39819f0\libraries


No, not there.

I will call my library blinkLED. So I make that folder, which is now: /home/nick/sketchbook/libraries/blinkLED





Make a function prototype for any functions your library is going to "expose" to the end-user, and put that into a .h file, like this:

blinkLED.h

#include &lt;Arduino.h&gt;

void blinkLED (const byte which, const int times);


Important: You must include &lt;Arduino.h&gt; as in the example, or you will get compile errors.





Put the C++ code into a .cpp file, like this:

blinkLED.cpp

#include &lt;blinkLED.h&gt;

void blinkLED (const byte which, const int times)
  {
  for (int i = 0; i &lt; times; i++)
    {
    digitalWrite (which, HIGH);
    delay (500);
    digitalWrite (which, LOW);
    delay (500);
    }  // end of for loop
  } // end of blinkLED


Important: You must include the .h file created in step 2, as in the example, or you will get compile errors.




That's it! Restart the IDE now so it notices the new folder with the library in it.

Now our test sketch can just use the new library.

#include &lt;blinkLED.h&gt;

void setup ()
  {
  Serial.begin (115200);
  Serial.println ();
  pinMode (13, OUTPUT);
  blinkLED (13, 5);
  }  // end of setup

void loop ()
  {
  }  // end of loop




Testing

For testing I just keep the library files open in a separate text editor (I am using Geany these days, but whatever your favourite editor is).

You can make changes to the library source and save them. You do not need to restart the IDE if you do this. It will always pick up the latest version.

In the IDE you alter your calling code, upload and test. It is really quite fast and simple.



Git

Once you have put a bit of work into your library you probably want to put it under source control. Using a terminal/command window, navigate to the library folder and put it into a Git repository:

git init
git add *.cpp
git add *.h
git commit -m "Initial commit"