Heat oven to 400° F. Lightly coat a 9-inch square baking dish with vegetable cooking spray.
In a medium saucepan, over medium heat, melt the butter and add the onion; cook until softened, about 10 minutes. Remove from heat, stir in the flour, then whisk in the milk, rosemary, salt, and a few grinds of pepper. Heat to boiling, whisking constantly. Stir in the sweet potatoes. Transfer to the baking dish and sprinkle with the Cheddar and bread crumbs. Bake for 30 minutes or until golden.