Before the launch of Xcode7, it was impossible to test your developed iOS apps on a physical device without enrolling into the Apple developer program. This is a membership program that cost 99USD annually. But starting from the launch of Xcode7, it is now possible to test your apps free on your iPhone or iPad device by signing in with your Apple ID.
In todays article, we will be going through the steps of running and testing your iOS apps on your iPhone, as you develop in Xcode environment.
Some of the requirements for achieving this includes having:
(1) an Apple ID
(2) An iPhone or iPad and its cable
(3) Xcode IDE
(4) Internet connection
Download and Install Xcode from Appstore or iTunes
Ensure that the minor update of your Xcode and iOS device matches. You can confirm this in Xcode by clicking on Xcode and then click the ‘About Xcode‘. Also, this can be checked on your iPhone by going to Settings > General > About to check the version, as shown in the image below.
Open your project in Xcode IDE. For this demonstration, I have set up a Single View App called ‘testapp‘.
Once you open your project in Xcode, navigate to the project tab and click on the ‘General’ tab. Make sure you have a bundle identifier set, as this will uniquely identify your project. Check the box “Automatically manage signing” as shown above. This allows Xcode to create, update your profiles, configure your developer certificate and also handle code signing for you.
As shown in the image above, click the drop down menu and select your Apple ID if your have already registered for one. If not, click on “Add Account” to create a new Apple ID.
The account will appear in the drop down list in Team, once we have created the Apple ID. Select it as the Team to use for your project.
Connect your iPhone to your MAC. This connection must be done via cable for the first time, but subsequently, you can choose to run apps on your iPhone over a network without a cable connection.
Your iPhone should now appear in Xcode IDE under Product > Destination, as shown below. Select the iPhone as the deployment target.
In order to setup a network connection to avoid using cable subsequently, first of all ensure that you have a network connection, to which both your Mac computer and the iPhone device are connected. While the iPhone is still connected to your computer via cable, click on Window and select the ‘Device and Simulators’ from the drop down options as shown below.
Once selected, follow the steps shown in the image below by clicking on the Add sign to pair your iPhone and your computer. Check the ‘Connect via network’ as show in (2) and you should see a network icon show up as appeared in (3) in the below screen shot. At this point, you have successfully setup your iPhone to communicate with your computer via the network.
Now you are ready to run the app on your iPhone by clicking the build and run button, as shown below.
Once the app has been successfully loaded, your app will now appear on your device screen as shown below.
In case you are having challenges side-loading your app on your iPhone, here are list of things to be aware of.
(a) We must make sure that the iPhone is unlocked.
(b) During side-loading, it’s very likely you see a popup requesting your password for Keychain. Make sure to insert your password as many times the popup shows and click the “Alway Allow” option.
(c) The process will definitely fail the first time you are loading an app to your iPhone, stating that you need to trust the developer of the app trying to run on your phone. At this point:
– Go to settings on your iPhone
– Click on General
– Click the Profile and Device Management and therefore trust the developer.
– Go back to Xcode and run the app again, and all should be fine.
(d) In case you are still facing any problem, unplug your iPhone device, shut down Xcode. Re-launch Xcode and plug your iPhone, try to run the app again and this should work.