Spanish wages grew only 2.7%/yr L10Y [1], and its nominal GDP/capita looks completely flat [2].
This explains why the city is affordable for international tourists but not locals. Regardless, a high "tourist tax" would probably be better for their economy than an outright ban.
[1] https://www.ine.es/jaxiT3/Tabla.htm?t=59150
[2] Compare https://www.wolframalpha.com/input?i=spain+gdp+per+capita+10... vs https://www.wolframalpha.com/input?i=USA+gdp+per+capita+10+y...