All right, guys. 1
So now that we've built our app, we're finally ready to actually run the app. And running our app is the 2
process where we turn our code into the actual app. 3
And this is done using Xcode, of course. 4
So there's two ways of running our app, 5
either we could run it onto a physical iPhone or iPad device or we could use the Xcode Simulator which 6
creates a simulated iOS device on our Mac. 7
Let's first look at how to run on the simulator because it's really, really easy. All you have to do is 8
to go up into this top left corner, click on the app name, and then in the dropdown list, you can select 9
the simulator that you want to use, 10
so the simulator device that you want to run your app on. 11
Now, in my case, I'm going to choose the iPhone XR, and then all you have to do is just hit the play button. 12
So just like iTunes, you can run by hitting the play button and hit the stop button to stop running the 13
app. And you can watch as the progress happens up here. 14
And once it's done, it should automatically open up the simulated device by itself. 15
Now, the first time you run your app it might take a while for the simulator to load up. 16
It's just like called starting your iPhone. 17
But after the first time this happens, then using the same simulated device should take a couple of seconds 18
for it to load up your app. So I fast forward the process a little bit, but it should take anywhere between 19
one to five minutes for it to load up for the first time. And then once, it's done you should see a blank 20
screen for a couple of seconds or more, and then it should display your actual app. And you can move the 21
simulator around just by dragging on its name. 22
And then if you hover around the edge, you can actually resize it to the size that you prefer. And you 23
can even go to the Hardware menu here and click on various things, such as the Home button or to rotate 24
the app left and right. Now at the moment because we've designed our app on a iPhone 11 or an iPhone XR 25
canvas, the diamond and the text is only going to look centered on devices with the same aspect 26
ratio, 27
so the XR, the 11, or the X. Now, in coming modules, we're going to learn how to make this right and 28
set rules for our display. 29
But for now, if you have a physical device that has a different aspect ratio, so you had one of the plus 30
sizes, then you can actually just simply change the canvas 31
right here in the size Inspector, update the design. 32
And then when you run it, it should look exactly as you see in the canvas. 33
So now that we've seen how easy it is to run the app on the Xcode Simulator, the next step is to run 34
it on a physical iPhone. 35
Now if you don't have a physical iOS device, an iPhone, or an iPad, then feel free to skip the rest of 36
this lesson and continue on to the next module. 37
But if you do have a physical device and you want to be able to see your app running on it, then continue 38
ahead with me. Now running on a physical device because it has all of your sensitive pieces of data and 39
a lot of personal information, 40
it's a little bit harder than running it on the simulator. 41
So there's a six step process that we're going to go through and I'm going to run through it with you 42
step by step. 43
So the first step is to check that your Xcode and iOs versions match. 44
Now what do I mean by matching? 45
Well, if you head over to Xcode and go to About Xcode, you should see the version of your Xcode. 46
And currently, I'm running 11.0. So for Xcode version 11.0, you will know about 47
iOS versions 13.0 and below. 48
If you have a physical device that's running iOS 13.0, you're perfectly aligned with 49
the Xcode version. 50
Now how can you find this information out? 51
Well, it's easy as going to the Settings and then General and About, and somewhere in this list, you should 52
see your software version. 53
Now I know I'm showing this to you on the simulator, but if you do the same on your iPhone, on your iPad, 54
it should be exactly the same process. 55
So the easiest way is to update your Xcode and update your iPhone or iPad both to the latest versions, 56
and then check that the number after the decimal place actually matches. And notice how Xcode 11 is 57
the matching version for iOS 13. 58
So if you had Xcode 10, then it won't know about iOS 13. 59
So you'll have to update Xcode. 60
But the easiest way of making sure that everything runs perfectly smoothly is checking that you have 61
Xcode 11 and you have iOS 13, and that the number after the decimal place matches between your 62
Xcode and your iOS. So that's step one. 63
Step two is you have to add a Apple developer account. 64
Don't worry. 65
You don't have to pay for this. 66
You can simply just use your free Apple ID that you use to download apps on the App Store. Now in order 67
to do this, 68
you can go into Xcode and click on preferences. And then here, you should be able to add a Apple ID 69
by clicking on the Add button, select Apple ID, 70
and then, here, enter your Apple ID which is usually an e-mail and then your password. 71
And once you've successfully logged in, you should be able to see your app ID show up right here inside 72
the accounts tab. 73
So now that we've added our Apple developer account, it's time to sign our app. 74
So back inside Xcode. 75
Make sure that you've got your project 76
I Am Rich selected and your I Am Rich 77
Target selected, and then head over to Signing & Capabilities tab and make sure that the Automatically 78
managed signing checkbox is checked. 79
Now click on the Team dropdown list and then select the account that you've added just now 80
or if you have a developer account like I do, then you'll see your team's name or your company name in 81
there. 82
Now if you don't see anything in here, you only see none, 83
then make sure that you've actually added your account successfully and that you see it underneath here 84
as an Apple ID. 85
So once you've selected your team, all the errors on this page should go away. 86
But if it doesn't and you see an error that looks like this, something about failed to create provisioning 87
profile, then it might be because you haven't got your device connected using a USB cable. 88
So just continue on and watch the next step of the video and then you'll be able to click on this try again 89
button here, 90
and the errors should go away. 91
Now just remember that we've also created that Sideloading Troubleshooting PDF Guide which you can 92
download from the previous lesson, so that if you encounter any issues with sideloading your app onto 93
your physical device, then you'll be able to refer to that and resolve any problems there. 94
And we should now be ready to actually connect our device. 95
So we'll do steps four and five together. 96
Grab your USB cable and connect your physical device, your iPhone or your iPad to your Mac. 97
Now at this point, you might see a pop up show up on your phone which asked you whether if you trust 98
this computer. So go ahead and tap on the Trust button and it might also require you to type in the phone 99
device passkey and follow the on-screen instructions to complete that process. Now that you've successfully 100
connected your device and trusted your own computer, 101
it's time to run your app. 102
So go ahead and click on the top bar here and select your physical phone as the device that you want 103
to run your app onto. 104
Now you might get a warning here saying something like device iOS version lower than deployment target, 105
something along those lines, 106
and that's just because you need to update your iPhone or your iPad to the latest version of iOS that's 107
compatible with Xcode which we talked about earlier on. 108
But once you've got your device selected, then go ahead and hit the play button to run your app. 109
And at this point, you might see a message like this, "iPhone is busy preparing debugger support." 110
You'll probably see this the very first time you connect your phone 111
and after every major iOS update. What's happening is that your phone has to tell your computer all 112
about itself, 113
like what kind of hardware it's running and its crash logs amongst other things. 114
I've seen this take anywhere between 2 and 15 minutes, so you might just have to be a little bit patient. 115
At some point, 116
it'll all be done and the window will disappear. 117
You should then see the app open up automatically on your phone 118
and it's really important that you let Xcode always automatically open the app even if you see the 119
icon as I do right here. 120
If you tap on it, it usually means that you're actually opening a slightly older version. 121
It's always best to wait for Xcode to do its thing. 122
Now if when you run your app and the end result looks a little bit crooked like this, then it might be 123
because you've got a different screen size compared to the one on your canvas. 124
So here, my design is created on an iPhone 11 canvas, but I'm running it on an iPhone SE. So, say, if you 125
had a physical iPhone SE or an iPhone 4 or something that basically has a different aspect ratio to 126
your canvas, then the end result of your design will look a little bit weird like this. 127
So in later lessons, we're going to be learning about something called Auto layout and setting constraints 128
where we're going to fix this so that our designs always look the way we want 129
no matter which screen size it's being run on. 130
But meanwhile, if you want to fix this and you wanted to look good on your physical device, then you can 131
simply go and change the device to match the device that you actually own. 132
So for example, if you wanted to run this on an iPhone SE, then we could change that 133
and then we can update the locations of our label and our image view so that when we run it on our device 134
again, it ends up looking the same as the canvas like this. 135
So now that you've set up your device and Xcode for running your apps onto your physical device, the 136
next time you need to run it, you don't have to repeat this process. All you have to do is to plug it in 137
select it, and then hit run. 138
And it's much much easier from now on. 139
Now so far I've shown you how to run your app from your computer 140
if you have a wired connection, but you can also run it wirelessly. 141
So I'm going to quickly show you how to do this. To start off, you need your phone to be connected to 142
your Mac with a wire. 143
We first have to use a USB cable and get the wireless side loading setup first. 144
Once you've got it plugged in and you can see it as a device right here, then go ahead and go to Window 145
and Devices and Simulators and you should see your connected device right here. 146
If you don't, 147
make sure that you repeat the previous process that we've gone through in order to make sure that it 148
shows up here. And then we're gonna go ahead and click the Connect via network checkbox. 149
Now it's really important that for this to work, your phone and your Mac has to be connected to the same 150
Wi-Fi connection. 151
So not only does your Wi-Fi have to be on both on your Mac and your phone, but you have to be using 152
the same Wi-Fi. But now, once that's done, you can unplug your phone and you'll see that you can still 153
find your phone up here in the devices. 154
And now if you hit run, you will be able to run it wirelessly across the Internet and show up on your 155
phone. 156
Now I'm not sure what your experience will be, but for me, I find that the wireless connection tends to 157
be a little bit unreliable. 158
So when I've got a cable with me, I'll always run my phone via the cable. And that way, I have a much smoother 159
experience when I'm testing my apps. 160
So that's it. 161
That's how you can run your app on a simulator, on a physical device, and even wirelessly. 162
I hope you had fun doing that. 163
And if you had any issues, be sure to rewatch the video because there were quite a few hoops that you 164
need to jump through before Apple is going to let you through the gates and allow you to get side loading 165
set up properly. 166
Now, once you're done, head over to the next lesson and I've got a challenge for you.