But....why? Design the slide to a frame or design a frame to the slide?
Why design a totally new frame when your goal is for a longer barreled gun? Glock made G17s forever and saw a benefit for a longer barreled gun (G34), that only required a new slide assembly. You're right, creating a new mold for a new frame would have cost money, probably made the gun cost significantly more. That would probably result in some guy/gal on a forum starting a thread bashing Glock for not just using a G17 frame to save money?
The slide was designed to work on the smaller frame. Look at the Glock 17L that proceeded the Glock 34. Glock didn't seem to think a longer frame dustcover was necessary either. Gun companies make decisions for a variety of reasons: asthetics, cost, performance, etc. Luckily the market is flooded with excellent designs that we have the luxury of choosing from. Personally I liked the G17 and G34 using the same slide because I could get two guns in one with the purchase if a slide. Same goes for a lot of other models now that the Glock 47 was introduced.