Check out a free preview of the full iOS App Development with Swift course
The "Build & Run App in Simulator" Lesson is part of the full, iOS App Development with Swift course featured in this preview video. Here's what you'd learn in this lesson:
Maximiliano demonstrates editing the metadata of the course application and how to run the application through an iOS simulator. The iOS simulator will run using the computer's processing power, not an iPhone, and therefore may not accurately show application performance.
Transcript from the "Build & Run App in Simulator" Lesson
[00:00:00]
>> Also, you can click in the name of the project and you will get also some metadata configuration. So when you wanna change the metadata such as the name of the app in the iOS, here you have a lot of options such as display name, the version number of your app.
[00:00:19]
Or for example, if your app is compatible with iPad, for example, I can untick that now my app is not iPad compatible. That doesn't mean that your app is not gonna work on iPad. It's gonna work on iPad, but as an iPhone simulator, okay. It doesn't matter. But just to know that here you can set up some metadata of your app.
[00:00:43]
Without touching anything else, you can actually run the app. So before actually running the app, maybe you're asking, okay, where is the app is going to run? I don't have an iPhone. Well, actually, on the top, we can see here that says iPhone. This actually my iPhone because I have my iPhone connected through USB.
[00:01:09]
But instead of using my iOS device, I can select an iOS simulator having mine working on that section of the screen. So if you click there, you can select an iOS simulator and the iOS simulators are actually coming with Xcode. So if you have installed Xcode, you have all the simulators available.
[00:01:32]
So you can pick any iPhone like an iPhone 13 Pro or mini, anyone, iPhone 13, and now I can try directly this play button. There is actually running the current project in that simulator. That's make sense and that will open that simulator. The first time it will boot up as actually a real iPhone.
[00:02:00]
So it takes a couple of seconds, and you will see hello world, okay? So this is actually an iOS simulator. So it's called simulator. Also for example, an Android, they are known as emulators. Does anyone know the difference between a simulator and an emulator without saying that the simulator simulates and the emulator emulates?
[00:02:25]
So an emulator is typically a built on machine, so it's actually emulating the hardware and on top of that, the full OS is there. An a simulator it's an app that looks like but it's not really. So it looks like an iOS but it's not really an iOS.
[00:02:42]
Let me prove that, I will on my Mac open the activity monitor that is like the task manager of the Mac, and they will search for coffee masters. And you can see that there is an app with the named coffee masters running on my Mac. So it's a process running on my Mac.
[00:03:01]
If I kill the process, let me move for a little bit. It's out of the simulator. So that proves that this is not a built on machine. So these apps are actually running on my Mac. With an iOS as kin or wielding an iOS as kin, but they are running on my Mac as a Mac process, because it's actually a similar platform MacOS, iOS, watchOS, TVOS.
[00:03:29]
They have the same architecture, okay. So, that means that for example in terms of performance it might not be the same as a real device. Is the performance of your Mac that can be better or worse than the real device so have that in mind, okay, it's just a simulator.
[00:03:48]
However, the UI and the the API's available are the same. So the framework, it's actually complete. It's the same framework that we have on the real device, but it's running on the Mac, okay. Does that make sense? So, quick things around the simulator. You can resize the window.
[00:04:11]
Just you take it from a corner and you resize a window like that. You can, there is here a home button. So you can click on that home button or you can use some shortcuts it's Ctrl Shift H, I'm sorry Command Shift H. And if you press that twice it opens the multitask mode, also if you forget about that you can go to the menu in the simulator and you have all those options.
[00:04:40]
For example, home, and here you see the shortcut. You can rotate the device. And if you want a shortcut for that, it's simple to remember its command right key, command left key to rotate right or left. Okay, so that's actually pretty simple. And with that, let's say that after you are running your app.
[00:05:05]
If you go to the home, your app, it's installed. It's this one. It doesn't contain any icon yet, but it's there, okay. Even if you close Xcode and you terminate the debug session, your app is still there. Okay, empty, but there, you have any questions at this point?
[00:05:31]
For now it's simple. Now, let's look at the files. By the way before doing that, so if you look at my screen if I sham to Xcode my simulator is still there sitting on top of every Window. That's because I set so in the Window menu, so you can go to the Window menu and enable or disable stay on top.
[00:05:57]
It depends on the case it's useful or not. Right now I'm going to disable that. So now if I'm going through Xcode, the simulator is behind Xcode. So it's not actually using the same space. So if you go to coffee masters app, this is what we find. This is kind of the main of the app, the entry point of the app.
[00:06:21]
If you look at the code, it's just a structure, okay. So it's not a class. It's a structure. Remember and when we are busting our structures, we are making copies and it's high performance. It's a structure, and here it says colon app. And this point, you're thinking, hey, Max, you lied to us, you mentioned that there is no superclass.
[00:06:43]
Well, actually, if we ask for help over app and we do that with option click. It says here that app is not a class or a structure, its a protocol. So actually this says that we are conforming to a protocol that's the verb that we use in swift.
[00:07:05]
We conform to a protocol, that's like implementing a protocol, okay. So, it's just that it's not actually inheriting from app, it's just implementing a protocol. And what's the protocol well if you get into the help if you scroll down you'll always have here open in developer documentation. And then it opens a fullscreen help on that particular element that will explain what it is?
[00:07:34]
What you can do with that? And it will explain you what you need to implement. For example in this case you need to have a property, with a name body. That's actually the requirement. So if you are conforming to the protocol, you are forced to have that body property.
[00:07:53]
With that name.
Learn Straight from the Experts Who Shape the Modern Web
- In-depth Courses
- Industry Leading Experts
- Learning Paths
- Live Interactive Workshops