I had a lingering cough during pregnancy too, mummy, and the rib pain was honestly worse than the cough 😭 What helped me was drinking warm water frequently, honey with warm lemon water (if okay for you), and sleeping slightly elevated at night.
For the rib pain, I used a warm compress and tried supporting my side with a pillow when coughing. Hope you feel better soon, mummy ❤️