They do speak Spanish -Castillian in Barcelona, as there are plenty of non-Catalan immigrants from the rest of Spain there, as also many foreigners who rarely speak Catalan. It is a fairly cosmopolitan place.
Catalan is also a fairly recently revived language. A hundred years ago it was mainly spoken in rural villages, the cities being mainly Spanish speaking. It’s only recently that its been revived as a vehicle for nationalism.
A great-uncle came from Barcelona in the 1920s, with impeccable Catalan ancestry, and he spoke no Catalan. That’s how it was.
Part of the Catalan nationalism thing is a reaction to foreigners (Spanish from elsewhere as well as non-Spaniards such as Eastern Europeans, etc.) swamping the locals.
I’ll be swamping the locals there next week! Barcelona is such a classy place.
A few brief additions of note ...
Catalonia has its own language that was suppressed during General Francisco Francos 1939-75 dictatorship.
The name Catalonia dates back to the 10th Century, so this identity is nothing recent.
Catalonia was swept into a “greater spain” when King Ferdinand II of Aragon, and Queen Isabella I of Castile married in 1469. Political power gradually centered on the Spanish crown, at the expense of Catalonia.
Catalonia revolted in the mid-1600s.
Since 1978 Catalonia has achieved more autonomy when it was defined as a “nationality” in the Spanish Constitution, but of course is subject to Spain’s power.
The economy is robust and is the strongest in Spain.
Best I can do as a summary. There is an extensive history going back through all Europe’s history, which has no exterminated the language, independence or culture.
I’m rooting for them.