In a medium skillet melt butter over medium heat. Add onions, salt and pepper. Cook, stirring often and adding water by the drop, to avoid scoorching, until onions are very soft and deep golden brown, 15-20 minutes. Add in the vinegar and sugar and reduce until the onions are glazed. Keep warm.
Parboil the potatoes in salted water 3/4 of the way done, about 15 minutes, and then drain and cool until able to handle. Cut them into 1/4 inch cubes.
In a 9-10 inch ovenproof skillet, heat the oil over medium heat. Add the potatoes, 1/2 teaspoon salt and 1/8 teaspoon pepper. Cook, uncovered, turning occasionally, until they are browned, 12-15 minutes. Spread potatoes out evenly in skillet.
Position the broiler rack about 6 inches from the source of heat and preheat the broiler.
In a medium bowl, whisk the eggs, rosemary (if using), the remaining 1/2 teaspoon salt and 1/8 teaspoon pepper, caramelized onions and half the cheese until well-combined. Pour over the potatoes and reduce the heat to medium-low. Using a rubber spatula, lift up the cooked part of the frittata and tilt the skillet to allow the uncooked eggs to run underneath. Continue cooking, occasionally lifting the frittata and tilting the skillet as described until the top is almost set, approximately 5 minutes. Sprinkle with remaining cheese. Broil until the frittata is puffed and the top is set,.