It's not that simple. Some of us (I'm a redhead) sunburn so easily, getting enough sunlight to avoid vitamin D deficiency means either near-constant sunscreen application or else a long-term risk of skin cancer.
My doctor emphatically told me to take supplements rather than to spend more time in the sun.