Dealing with a friend who always leans on me
He's a postgraduate, and so are you. A postgraduate degree is self-guided study. And while there's scope for group working and collective problem solving, hand-holding him is actually making his situation worse, not better.

In other words, by doing his work for him, you are hindering him. If he truly is a friend, then it's time for you to stop hindering him.

Explain to him that you have been preventing him becoming a fully-fledged researcher, and apologise for that; remind him that the purpose of the degree is to build research skills, self-discipline, and independent thought, and that when he asks you to do work for him, you're both complicit in preventing him from achieving these goals. And so it's got to stop, for his sake, and for your sake in not being complicit with what's going on.