Affordable housing is little better than the drinking fountains for colored people from years past. You don't build affordable housing. You build housing and then prices decrease from the increase in supply. If you're feeling extra bold, you build dense housing to massively increase the supply.
This is kind of true, but misses an important point. Builders won't increase the supply if unit price is close to unit cost as their profit would be narrowed. This is to say, if materials, labor etc is expensive, affordable housing may not be affordable either.
San Francisco's problem is "a worker shortage, long waits for permits, restrictive zoning and high fees" [1]. Three out of four of those are direct results of planning rules. The first, related to the high cost of housing.
Issue permits quickly, loosen zoning and make fees low and predictable and you'll see affordable housing.
[1] https://www.sfchronicle.com/bayarea/article/SF-is-one-of-the...