It's obviously both. If you're a heroin addict in West Virginia you just rent a trailer with a revolving list of fellow addicts for like $400 month and you beg or steal enough to get by. Plus, you're in a part of town where nobody is really going to notice you.
That doesn't work in San Francisco.
So did the heroin make you homeless or the high prices? It's kind of a silly question. It's both, in some sense.
That's why we see a direct correlation between the cost of rent and homelessness.