I lost the ability to do pull-ups due to shoulder problems (first one shoulder, then the other) followed by a neck problem. Here’s what worked for me:
First, the obvious: Chin ups, especially with slow descent; negative and/or partial pull-ups; scapular raises (basically pull-ups with locked elbows so that the raise is done with only the shoulder and back muscles); and seated and bent over rowing.
The less obvious things that helped were deadlifts - and I know that not everyone agrees that DL strength will help with pull-ups. But DLs will increase the strength in the muscles that enable you to keep your lower body tight which will help prevent swinging. DLs also increase grip strength and generally, the tighter the grip, the greater the number of pull-ups/chin-ups. In fact, not many can continue for many reps once the grip begins to weaken. Gripper work helped too.
Losing weight helped me, and so did focusing on proper pull ups form. The pull-up is a whole body exercise and requires the abs, glutes, and legs to be tightly contracted. In addition, I found that at the top of the pull-up, the face/neck should not be as close to the bar as with a chin-up. It’s like leaning back a little during the ascent. I have no idea why this works, but for me it works like a charm.
I also followed the FPP program, but started with fewer reps, and didn’t feel defeated when didn’t make progress as fast as the FPP suggests.
Finally, it sounds dumb, but I eventually realized that as I neared the top of my rep range, I was forgetting to breathe or breathing only shallowly. For me, breathing with the proper cadence was a bit tricky.