To send your app out to beta testers and eventually real users, you must first archive your app using Xcode. Archiving your app will package up all contents, code, and assets. To archive your app, you must select Generic iOS Device from the list of devices your app runs on in Xcode:
With this build device selected, select Product | Archive from the top menu in Xcode. When you do this, a build will start that's a lot slower than usual. That's because Xcode is building your app in release mode so it is optimized and can run on any device.
Once the archive is created, Xcode will automatically open the organizer panel for you. In this panel, you get an overview of all apps and archives that you have created:
Before you archive your app, you should make sure that your app is ready for release. This means that you must add all of the required app icon assets to the Images.xcassets resource. If your app icon set is incomplete, your app will be rejected when you try to upload it to App Store Connect, and you'll have to generate your archive all over again.
When you're ready to upload your build to App Store Connect to send it to your beta testers and eventually your users through the App Store, you should select your latest build and click the Upload to App Store button. A popup will appear to guide you through a couple of settings. You should use the default settings most of the time and click Next. Finally, your app will be verified based on metadata and uploaded to App Store Connect. If there are errors in your archive, such as missing assets or unsigned code, you'll learn about it through error messages in the upload popup window. When your upload succeeds, you'll also be notified through the popup.
Once you've uploaded your build, you can go to the activity panel for your app in App Store Connect. This is where you'll see your build's current status. If you have just uploaded a build, its status will be Processing. Sometimes this step takes a while, but usually no longer than a couple of hours:
While the app is processing, you can start to prepare your TestFlight settings. Select the TestFlight menu item and fill in the Test Information form. If you're rolling out your beta test internationally, you might want to provide information in multiple languages, but you don't have to.
Next, select the Internal Testing menu item in the sidebar on the right. In this panel, you can select users that are added to your account for beta testing. This type of testing is often the first type of testing you do, and it's mostly intended for testing apps internally with members of your team or with close friends and family. You can add more internal users to your account through the Users and Roles section in App Store Connect.
Once your app is processed, you'll receive an email, and you can select which version of your app should be used for internal testing:
Once you've added testers and you've selected a build to test, you can click the Start Testing button to send out a beta invite to your selected testers. They will receive an email that enables them to download your app through the TestFlight app for iOS.
Once your internal testers are happy with your app, you can select some external beta testers for your app. External testers are typically people who aren't in your team or organization, such as existing users of your app or a selection of people from your app's target audience.
Setting up an external beta test is done identically to how you set up the internal test. You can even use the same build that you used for internal testing for external testing. However, external tests typically require a quick review by Apple before invites can be sent out. These reviews don't take long and passing the beta test review does not mean you'll also pass the App Store review.
This is all you need to know about setting up a beta test through TestFlight. When you're happy with the results of your beta test and your app has passed the real-world test, it's time for you to prepare to release your app into the wild through the App Store.