In this work we considered the quantum Otto cycle within an optimization framework. The goal was maximizing the power for a heat engine or maximizing the cooling power for a refrigerator. In the field of finite-time quantum thermodynamics it is common to consider frictionless trajectories since these have been shown to maximize the work extraction during the adiabatic processes. Furthermore, for frictionless cycles, the energy of the system decouples from the other degrees of freedom, thereby simplifying the mathematical treatment. Instead, we considered general limit cycles and we used analytical techniques to compute the derivative of the work production over the whole cycle with respect to the time allocated for each of the adiabatic processes. By doing so, we were able to directly show that the frictionless cycle maximizes the work production, implying that the optimal power production must necessarily allow for some friction generation so that the duration of the cycle is reduced.