Open Xcode and create a new Single View Application. For product name, use SegmentedControl and then fill out the Organization Name and Organization Identifier with your customary values. Enter Swift as Language and make sure only iPhone is selected in Devices.
Drag a Segmented Control to the main view.
Copy and paste this code to your .swift file and Run.