Although you'll be able to go through most of the exercises in this book using the Simulator, it is recommended to build and test your apps on an actual iOS device, as the Simulator will not be able to simulate some hardware components and software APIs.
https://help.apple.com/simulator/mac/current/#/devb0244142d.
In addition to your device, you'll need an Apple ID or a paid Apple Developer account to build and run your app on your device. You'll use the same Apple ID that you used in the App Store for now:
- Use the USB cable to connect the iOS device to your Mac.
- In the Scheme menu, choose your device (iPhone in this case):
- Wait for Xcode to finish indexing and processing, which will take a while. Once complete, Ready will be displayed in the status window.
- Run the project by hitting the Play button (or use command + R). You will get the following error: Signing for "Exploring Xcode" requires a development team:
This is because a digital certificate is required to run the app on an iOS 13 device, and you need to add an Apple ID or a Developer account to Xcode so the digital certificate can be generated.
- Click the Add Account... button:
- The Xcode Preferences window appears with the Accounts pane selected. Enter your Apple ID and click Next. Note that you can create a different Apple ID if you wish using the Create Apple ID button:
- Enter your password when prompted. After a few minutes, the Accounts pane will display your account settings:
- Close the Preferences window when you're done by clicking the red button in the top-left corner.
- In Xcode's editing area, Click Signing & Capabilities. Make sure Automatically manage signing is ticked and Personal Team is selected from the Team pop-up menu:
- If you still see errors in this screen, try changing your Bundle Identifier by typing some random characters into it, for example, com.12345myname.Exploring-Xcode.
- Everything should work now when you build and run, and your app will be installed on your iOS device. However, it will not launch and you will see the following message:
This means you need to trust the certificate that has been installed on your device.
In the next section, we will see how to do that.