Unlimited Plugins, WordPress themes, videos & courses! Unlimited asset downloads! From $16.50/m
by
Lessons:19Length:2.3 hours
Swift400
  • Overview
  • Transcript

2.1 Create a watchOS Project

Now it's time for us to get started. And like any other good project, the best place to get started is at the beginning. So the first that we're gonna wanna do is create a watchOS application, or a watchOS project, within Xcode, so we can get started. Now there's a couple different ways that we can do that. We can take a look at the welcome screen that we see here the first time you open up Xcode. And you can select Create a new Xcode project. Now if for some reason this is not here, you can always come up to File and select New Project. Or if you would like to use the welcome screen and it's not there, you can come over to Window and select Welcome to Xcode. So now that we've gotten that under control, let's go ahead and select Create a new Xcode project. Now there's a couple of different ways that we can create a watchOS application. We can start from a iOS application. That's just for the phone. And then add in the capabilities and the functionality for a watchOS app. Or we can just start from the beginning and have everything bundled together. And in this course, since we're starting from scratch, let's go ahead and do that. So when we're in this screen here, to select a template for our new project, we're gonna select watchOS. And then under Application you can see iOS App with WatchKit App, so let's go ahead and select that. We're going to click Next. And now we can select a Product Name. Now I'm going to call this RemindMe. You can call it anything that you'd really like to. And we'll talk a little bit about why I call it that and kinda the motivation behind this application, for me anyway, in some of the upcoming lessons, but I'm gonna call it RemindMe. You can give it an organization name, where you could put your company name here if you would like. Or if it's just a personal application, you can put your name in here. And then create an Organization Identifier. Now an organization identifier is typically in reverse DNS notation. So we're looking at com dot something, is usually one of the more common ways to define these. So, you would usually say com dot, and then your company name, if you are doing this as a company, with all of the spaces removed and typically lower case. It's not required, but typically. And then once you filled all those things in, you can, or it will generate a bundle identifier for you by combining the organization identifier and the product name and having all of the spaces removed. So that's just the basics of how that works. So then the next thing we're gonna wanna do is make sure we've selected the proper language. So we wanna make sure we select Swift, since that's what we're gonna be using in this course. And then for devices, we have the options of, right now anyway, on my machine, of doing iPhone and Universal. So in this case, it doesn't really matter which one of these you choose, mostly because we're gonna be focusing on the watchOS part of the world, and not so much on the iPhone part of the world. You might say, but why does it matter? Well, it does matter because, watchOS apps are not capable of really living on their own. It's gotten a little bit better, whereas the watchOS apps can do some of their functionality on their own, disconnect from the iPhone. But there's still some of the heavy lifting of your app that will live on the phone. And will need to communicate back and forth, with the actual watch itself, but we're not gonna get into a lot of those details. We're gonna be focusing mostly on the watch, so I would just leave iPhone selected as the device for now, and we'll kinda talk a little bit about that later. Then we're gonna want to uncheck the notification scene. We're not really gonna talk about that. We're not worried about that so much for this particular course. But we will want to include a complication. A complication, sounds complicated, not really. It's really just a fancy word to say we want to be given a default user interface within our storyboard for our watchOS app to start with. So we can create one afterwards if you leave this unchecked. But a lot of times, it's just easier to have it thrown out there for you, and set all some of the basic properties up for you, so you don't have to worry about it. So that's why we're going to select Include Complication. So let's go ahead and click Next. And now we can select the location of where we want to save this. I'm gonna leave it on the Desktop, I think that's gonna be fine. And them I'm gonna leave Create Git repository on My Mac selected. Now you don't have to do this, but I would say that it's probably good practice that every time you create a new application, especially in Xcode, you might as well create a git repository with it. Now we're not gonna be doing anything with the git repo in this course, but it's just good practice to have it there so that you can use some source control, even if it's just locally. Even if you're not pushing it to get Github or Bitbucket or something like that, it's at least good to have something on your local machine so that you can save your changes as you go. But like I said, we're not gonna focus on that in this course. So let's go ahead and click Create, and now we have our basic project structure set up within Xcode. So what we're looking at here, on the left hand-side is going to be our project, which is called RemindMe, and we have four folders underneath it. The first folder, called RemindMe, is actually just all of the files, all of the assets, all of the storyboards of the main application that's gonna be running on the device itself, or on the phone itself. So this is for a phone, or if it's a universal app or something like that, this is where all of that code is going to live. So we can kind of keep things logically separated. You can share things between these, targets, they're called. And I'll show you how to do that later on because that's a good practice, or a good thing to understand. So just remember, the RemindMe folder here, or the remind me target, is gonna be what's gonna run on the actual phone itself. Then in the WatchKit app folder in here, or the WatchKit app target, this is where we are going to have all of the user interface components that are actually going to be running on the watch itself. So, typically, in here all you're going to see is the storyboard, which is gonna contain all of your complications and the scenes and the user interface pieces that are going to be running on the actual watch themselves. And that's kinda how that logical separation goes. And then you're gonna have the WatchKit Extension, which is where you're going to put all of the code that helps to run the UI pieces that are going to run on the watch. So the way that this kind of works is you have your RemindMe app that is going to be running on your device, on your phone. And then you're gonna have your extension, which is also going to be kind of running on the phone and communicating back and forth with the actual watch itself. And then you have the actual WatchKit app, which are the pieces that run directly on the watch itself. And that's kind of the breakdown of how these three targets work. Then in the Products folder, you're gonna have one product for each of those targets. You're gonna have the RemindMe.app, which is what is, once again, going to run on the phone. The WatchKit app, which is going to obviously run on the watch. And then the extension, which we're not really gonna worry about too much, but that is kinda that bridge between those two worlds of the phone and the watch. So that's the basic breakdown of the project structure here. We're going to be touching all three of the top ones. We're not gonna worry about the bottom one, because that's basically the result of the build process that we're gonna go through once we've written our code and created our application. So that's the basic structure of our watchOS app that we're gonna be working on throughout the duration of this course. Now it's time to actually start writing some code.

Back to the top