Barcelona can be really hot in the summer! As such, I like to visit the city during the spring (April to June) when the weather is still sunny without being scorching. Alternatively, you can always schedule your visit in the fall (September to October).