Create an archive of your app to upload it to iTunes Connect or export it for distribution outside of the App Store.
In the main window, choose a target from the Scheme toolbar menu.
For iOS, tvOS, and watchOS apps, choose a generic device—Generic iOS Device, Generic tvOS Device, or Generic iOS Device + watchOS Device—or choose your device name from the Scheme toolbar menu. If a device is connected to your Mac, the device name appears in the Scheme toolbar menu. When you disconnect the device, the menu item changes to the generic device name.
Important: You can’t create an archive if the device is set to a simulator.
Choose Product > Archive.
The Archives organizer appears and displays the new archive.
Xcode runs preliminary validation tests on the archive and may display a validate warning in the activity view in the toolbar. If you see a warning, fix the issue and create the archive again.