As we have seen so far, we can run our apps on the Xcode simulator. However, if we want to test our app on a real device (iPhone, iPad, etc.), whether via USB, by creating an installable file, or uploading it to the App Store, we need to sign it with a certificate. This is done for security purposes, as it prevents malicious apps from being created and distributed without control.
To create this certificate, we need a developer account, which you can create for free at https://developer.apple.com.
This allows us to run our apps on real devices via USB, but if we want to distribute our apps through an installable file to other devices or upload it to the App Store, we need a paid developer account. We'll cover this type of account in future articles.
Adding our developer account to Xcode
Once we have created our developer account, we need to add it to Xcode from the preferences screen, which you can access from Xcode -> Preferences. Click the "+" button and select the Apple ID option.
Enter your email and password, then proceed with Two-Factor Authentication, which is mandatory, so you may need to activate it at https://www.apple.com/shop/account/home.
Once the account is added, select it as your Team and enable the "Automatically manage signing" checkbox in the Signing & Capabilities section. Xcode will automatically create the necessary certificates and use them when we launch our app.
Enable Developer Mode on your iOS device
Running your app on the device requires that you enable Developer Mode. On your iOS device, open Settings > Privacy & Security, scroll down to the Developer Mode list item and navigate into it. On a watchOS device that you use for development, go to Settings > Privacy > Developer Mode. To toggle Developer mode, use the Developer Mode switch.
Tap the switch to enable Developer Mode. After you do so, Settings presents an alert to warn you that Developer Mode reduces the security of your device. To continue enabling Developer Mode, tap the alertโs Restart button.
After the device restarts and you unlock it, the device shows an alert confirming that you want to enable Developer Mode. To acknowledge the reduction in security protection in exchange for allowing Xcode and other tools to execute code, tap Turn On, and enter your device passcode when prompted.
At this point, your device is ready to install and run apps from Xcode. After you have enabled Developer Mode the first time, Xcode doesnโt ask again unless you disable Developer Mode โ as described below โ or you restore the device. You can Build and Run from Xcode without further prompts to enable Developer Mode.
Be the first to comment