Run Your App on Your iPhone or Simulator
There are two ways in which we can run our app – either by using Xcode’s simulator or with our physical iPhone.
Using the simulator
To change the target device, click the device icon beside your app name…
…and select from the dropdown menu.
When you’re ready to test your app, just click the play button.
Using an iPhone (plugged in)
Before we begin, make sure you have your iPhone connected to your computer.
1. Check Xcode and IOS versions match
Just update both your phone and Xcode to the latest version.
2. Add an Apple developer account
You can use your existing Apple account to do this.
Xcode > Preferences > Accounts > Add in your existing Apple account or create a new one.
3. Sign the app
In Xcode, make sure you have project and target selected.
Then go over to the Signing & capabilities tab. Make sure that the Automatically manage signing checkbox is checked. Afterwards, click on the team dropdown menu and click on your name.
If you get any error messages like below, make sure you have your phone connected.
The next step, is selecting your iPhone device in beside your app name near the play button. Then click play.
Using an iPhone (wifi)
You can also test apps wirelessly.
You first need to connect your phone with a cable and see it show up in Xcode. Then navigate to…
…and tick the Connect via network option. Both your Mac and iphone have to be on the same network for this work.
Once you unplug your phone and run your app again, it will work wirelessly.