Developer Patrick Kennedy wants to build apartments for middle-class families near San Francisco’s Financial District, but he is struggling to win the city’s approval. The problem: in one spot the building’s courtyard is 5 feet too narrow.

Mr. Kennedy said his efforts constantly run up against such obstacles, which he said drive up the cost of construction and make it nearly impossible to build anything but luxury housing in one of the nation’s most expensive markets.

The...