Every city has a city office and they know the local ordinances.
Where I live in Northern California is it illegal to rent it out.., but not illegal to live in it on your own.., and not illegal to let a relative stay so long as it's not "permanent."
I let a family stay in our RV after their house burnt down and they were going to need to be there for 2-3 months. I asked the city what is "permanent" and they said it was not defined.., but if the neighbors complained we'd get a two week notice. If no one complained than we wouldn't. So, my guests were lights out by 10 and kept very quiet.
Our neighbors are nice and knew the circumstances anyway, it was never a problem.
But 'living in' and 'renting' are very different. People often stay in RVs while they are remolding or flipping a property.., that is very different than renting out a property. A single family residence (in most areas) is not to be turned into two lots.., which renting an RV would be. Same for adding an additonal building on your property.., you'd have to have permission and proper zoning.
That being said.., less than a mile away from me is considered out of city limits and the rules are all different there. Best bet is to check with the city office.