Running your code on your device used to be a complicated process that required a paid membership to Apple's Developer Portal. But now, it is literally one click! (With a lot of extra clicks).
- Plug your iOS device into your Mac using a lightning cable.
- Unlock your phone and click "trust" if prompted.
- On the top left section of the Xcode window where it says
iPhone 6S Plus(or something similar), select your device from the drop down menu. (If it says your device is unavailable because of the version, lower the
Deployment Targetin the project settings).
- Click the
Runbutton on the top left. It will tell you that there is no team selected, and that you need a team to run on the device.
- Let Xcode fix this issue for you by logging in with your
iCloudaccount. This is the same you use to download apps in the App Store. If you do not have an
Apple IDXcode will let you create one, and follow the onscreen steps in order to do so.
- Click the
Runbutton again. You may get an error that the device is not available yet because it is processing symbols. If so, there will be a progress bar you can watch while you wait. Then you can run it again.
But wait! Thats not all! Apple is very serious about security, and when you
side-load apps, they have not been screened in the same way ones from the App Store have, so you have to Trust the profile that Xcode just created for you that lets you run apps on your phone.
Great! Now you should be able to run the app. Try hitting the run button in Xcode again! If you want to run it in the simulator later, you can select the simulator in the same way you selected your device earlier!
Before you move on, let's take a look at what we just did:
Xcode not only allows you to build on a simulator (i.e. a fake iPhone that runs on your computer) but also on your physical iPhone or iPad.
In order to do this, we had to set up your iCloud account with Xcode, which lets your phone know that the incoming app is from you, and isn't going to do anything evil or malicious. Next, on your phone, you had to set yourself up as a trusted developer. This tells the device that the incoming app is coming from you.
Wondering why this process seems so needlessly complex? It all comes down to security. Apple wants to make sure that someone can't just plug into your phone and install an app that would steal all of your personal information, track what you type, or even watch your location!
If you have feedback on this tutorial or find any mistakes, please open issues on the GitHub Repository or comment below.