how many years he has been living in a country
You have used the correct verb form in your question, joeviee.
"How many years have you been living in Sweden?"
If you say " How many years it has been since you live in Sweden?" this means that your friend no longer lives in Sweden, and...