Hey there, I was just in Bcn for the past 5 months here are a few options:
1) Get your phone unlocked and use a spanish sim card. (I'm not sure how to do this but I know some people that did this with their iphones.)
2) Buy a pay as you go phone. they cost about 20 euro base price, they might load it with 19 euro of minutes when you buy it. they did it for me and my roommate, but not when my roommate had to buy a new phone bc he lost his. The companies you can use there are Orange, Vodafone, Movistar, among others. You can recharge it at any El Corte Ingles, a store of whichever provider you use or a the Tabbachi's.
Honestly, I liked having the pay as you go phone bc Bcn is notorious for being one of the worst pickpocketing cities. I could go out at night, be it to a sports bar to watch a football match with some friend or a crazy club, and I didn't have to worry about losing my more expensive american phone. The pay as you go plans work really well, you just want to make sure you don't run out of money on a sunday bc nothing is open.
Have fun!!! Barcelona is amazing! Hit me up if you want any advice of places to go!
EDIT: Calling charges in spain in general are not cheap, it is MUCH cheaper to text but calls can be kept short if you're efficient.
Also, are you planning on using this phone to call people in Spain, in Europe or in the US? I could never figure out how to call people that were outside of Spain on my pay as you go, calls to any other country I made with my US phone.