How do you get rochsmash in Pokemon platinum?

you go into the cave to oreburg and a hiker will give you it but you have to beat the gym leader first to use it