Building a basic iOS app is as simple as creating an Xcode project from a template. Once you've created the project, you've essentially also created an app. This movie shows how to get your app running in the Simulator and how to configure the Simulator so you can see the whole device on the screen at once.
- [Instructor] Simply creating an Xcode project, we've actually built an app. The app isn't beautiful by any means but it's an app none the less and we can run it and see what it looks like in the Xcode simulator. As I mentioned earlier we can test an application in the simulator by simply clicking the play button here. Now before you click that button, you wanna make sure that you're testing on the appropriate device. I'm going to be using an iPhone SE for this so I'm going to click away and then click the run button or use the keyboard shortcut Command + R to run the application.
Now the first time you do this, you're going to be asked to enable Developer Mode on this Mac so I'm going to click Enable to enable Developer Mode. Then you're going to need to authenticate, so I'll do that as well. Now this part might take a minute. What's happening here is your application is created, it launches the simulator, and your app is copied to the simulator, and then the simulator is shown on your screen. You are not going to see anything but a white screen but once you see that you know that it's working properly.
So at this point you want to wait for usually about a minute. If you have a faster computer, then maybe it'll take less time. Once everything's done, the simulator window will show up on your screen. You can also click the simulator in the dock and bring it up right here. So when we do that, we're seeing this Apple logo, and this progress bar. Usually what happens is the first time that you run an application, and the first time that you open the simulator, it's going to take a while to boot up.
Now you think of your phone, and how long it takes to boot up when you turn it on. Usually takes more than a second or two. Well, the simulator's kind of the same way. Once you've launched an application, and then you've closed it without quitting the simulator app, you can then launch another application much quicker than you could before. And the moment we are waiting for has come. The application is running in the simulator, and yes it is just a blank white screen with the carrier information at the top, and the time, and the battery status, and the application has kind of crashed, and this is another thing that's going to happen when you just launch the simulator for the first time.
And it is nothing to worry about at all. So I'm going to drag this guy down a little bit, and go back into Xcode. And it says, "unable to attach." So I'm going to click OK to close that prompt, and then what I'm going to do, is I'm going to click the run button again, and that's going to open up the application again, and when I do it this time, it's going to work fine. So there we go. So here's our application, and you'll notice these scroll bars on the bottom, so we have to use these to navigate around the application.
Now, if your resolution is higher than mine, you may not see these scroll bars. But what I like to do, is I like to re-size the simulator based on the resolution of my computer. Now I can do that by going to Window, Scale, and changing the scale. I think I'm gonna go to about 50%. That should get me right where I got the whole device on my screen, and I don't have to scroll at all. So here we have the iPhone SE simulator and it's running iOS 10, and this is our first application.
This beautiful, blank screen. So when you're done looking at your application, instead of quitting the simulator, I recommend going back to Xcode, and then hitting the stop button. So that way when you run an application again, instead of going through the long process of opening up the Xcode simulator, it'll happen right away. So we've successfully tested our first app in the iOS simulator.
- Installing Xcode and the iOS SDK
- Creating layouts
- Adding interactions
- Changing labels and text fields
- Troubleshooting UI-to-code connections