According to art. 5 of RD 557/2011, those non EU citizens who wants to enter Spain from a Schengen area country, while applying fot extension of his residence permit or applying for the new ID card for foreigners (TIE), will need to apply for a return permit.
The return permit will issued by the National Police Stations. If you are living in Barcelona City you will need to apply for an appointment at the following this web site.
For more information see:
Return permit - Official Information Sheet (in Spanish)