Heat the oil in a large cast iron skillet over medium heat. Add the mushrooms and onions and sauté until the onions have softened, about 3 minutes. Add the spinach, rosemary, salt, and pepper and continue to cook until the spinach is wilted, another 2-3 minutes.
Crack each egg into the skillet, arranging so they are evenly spaced across the mushroom mixture. Transfer the skillet to the oven and bake for 15-20 minutes until the egg whites have set. Serve warm