1) Spain does not have a problem with foreign people. Not any more than any other european country.
2) Tourism represents 12% of the GDP in Spain. It's not as much an impact as people seem to think abroad. There are 17 autonomous regions in Spain, the economy of each is widely different and some are more dependant on tourism than others:
While the tourism impact on the global GDP in Spain is of 11,6%, it can be has high as 44,8% on the balearic islands with over 30% of jobs related to it and as low as 6,9% in Madrid, with barely a 7% of jobs...
3) The main issue is not that all of a sudden Spanish people don't like foreigners or tourism. The thing is that the tourism model has been shifting towards the airbnb model.
4) People in Spain prefer to live downtown. It's a cultural thing. Around 82% of the population live in urban areas. People live in flats and walk everywhere, because of convenience, because they like to go to the bar across the street, they prefer not spending over 30 mins to get to the workplace, blablabla. It's the quality of life here and how people live full stop.
5) Due to this and the steady increase of population of the last 30 years (see graphic below), with currently over 48 million people total...housing is an issue, specially in big cities and the islands.
6) Because of the explosion of airbnb and similar flats the housing costs in these places have skyrocketed and speculation has gone rampant. Some have seen their monthly rent grow in some cases over 100% overnight.
7) The impact on GDP of these tourism flats and new business model is minimal. No direct jobs, no impact on what people spend in local commerce since these visitors buy at the grocery store, cook and drink at these apartments and that's it.
So, I leave it to all of you guys to put 2 and 2 together and come to a conclusion.