Unlimited Plugins, WordPress themes, videos & courses! Unlimited asset downloads! From $16.50/m
  • Overview
  • Transcript

2.1 The Project Structure

Now that we've seen what it is we're tracking to, what it is we're looking to build, let's go ahead and start to create our project using Xcode. And take a look at the basic project structure that you're gonna start with when you're creating this iOS application or more specifically, this iPhone application. Now I'm not gonna go through all the nitty-gritty details of Xcode and the actual iPhone or iOS platform itself, but I will call out some interesting features here and there just so that you understand them a little bit better. So you're not taking aback when you start to go through and actually play around with this. If this is your first adventure into the world Xcode and iOS development. So the first thing you're going to do is you're gonna open up the Xcode. And you're gonna have a number of different options here. So what you can do at this point is you can actually get started with a playground, and if you've never done that, I highly recommend that you go ahead and play around with that. If you go back to my previous course on the Swift programming language, I do a lot of work using the playground. It's a very interesting tool, it's very beneficial to really get started using Swift, especially if you've never done it before. So I would definitely recommend that for sure. You can create a new Xcode project, you can also open up an existing one. And you can also see a list of the previous things that you've done, previous files and, and a, and a number of other different things that you can do to get started. So, we're gonna go ahead and create a new Xcode project. And in this point, we're gonna be presented with a number of templates that we can use to create this particular application. Now, really, you can start anywhere. There's really no right or wrong answer here. What I typically do is select the Single View Application because that's pretty much lean and mean. It's gonna give you just the absolute basics to get started and not really overwhelm you with a lot of extra files and configurations, and things of that nature. So, when I'm first learning how to get in here and use Xcode and create these applications, I start there because, like I said, it's gonna give you just enough to get started. But before you check that, make sure that you are under the iOS family of templates here and you have Applications selected and then select Single View Application. So from this point, you can go ahead and click Next. And this is where you're gonna start to define the name and the basic characteristics and technologies that you're gonna be using for your application. So I'm gonna call this SwiftReader, as you saw in the previous lesson when, when you got to see exactly what it is we're trying to build. And then you can put in a whole bunch of different things here. Your organization name, identifier. Now the identifier is kind of interesting as this is the kind of reverse notation of what you would see as you would put something into say your web browser. So it's gonna be typically starting with com.something-like-a-domain-name-ish-type thing, and then at the bottom, it's gonna wind up creating this bundle identifier for you that's actually gonna concatenate the identifier and your product name. Now for the language, obviously we're gonna select Swift, but you could also continue to use Objective-C. You're not required to use Swift, but that's why we're here. And you can choose your devices, whether you want this to be an iPhone, an iPad, or Universal. But since we're just getting started using Swift to target iOS, we're gonna stick with the basics and we're gonna stick with iPhone. And then, upcoming courses we'll start to dig into some of the other things as we go. Now Use Core Data, this checkbox down here, if you've never done any sort of iOS development or if you've never used Core Data, don't be intimidated here, leave this checkbox checked. We're gonna use Core Data a little bit later in this course to show you how to save data that the user is inputting, into a local storage medium which just so happens to be SQLite in this particular implementation in iOS. But this is going to allow us to kind of do database type things and I'm gonna define what I mean by database type things later on in the course. But just leave this box checked because this is gonna allow us to do some pretty cool things later on in the course. Then we'll go ahead and click Next, and now we're going to be asked where we wanna put this. And so, I'm just gonna leave it in My Documents folder for the time being. And you can create a get repository here if you would like. That's fine. I'll leave it checked for now. And then, we'll go ahead and click Create. Now, this will go through the process of creating the project for me, and doing a whole bunch of things like adding configurations, adding files, and a lot of basic stuff like that. So I'm gonna open this up a little bit, so we can see a little bit better. I'm gonna take you through kinda what the project structure is and what we're looking at here. So you're given three folders, and if you don't see this view, up above here you have a number of different button options here. Make sure you have the one on the far left selected and this gonna show your Project navigator. So you'll see three folders here, SwiftReader, SwiftReaderTests and Products. So if you take a look at SwiftReader, we can go ahead and take a look at some of these files at. Now if you've done iPhone or iOS app development before, this is gonna seem extremely familiar to you. And if you haven't, then there's a little bit more to it, so I would definitely urge you to read up a little bit more on developer.apple.com. Cause I'm not going into very deep details on a lot of this stuff, but you'll kinda get the basic ins and outs. Now the AppDelegate, this is going to provide a class where you basically, from within your application, kinda have that system level ability to see what's going on with your application with respect to the system. So this also defines what's known as a window, and everything within your iPhone application in this instance is going to run within a single instance of a window. So the AppDelegate's job here is to create that window and have it available to you so that you can put some information into it. And as you can see here, we have basically some, some methods, or almost advance if you will. We have didFinishLaunching, we have WillResignActive, DidEnterBackground. So there's a lot of system level type events that you can start to work with here when you're creating your application. We're not gonna do a whole lot in here as far as these are concerned, but a little bit later, we're gonna talk about this Core Data which is kinda nice that it's all set up for you here by default. So, there's not really a whole lot of stuff you have to worry about as far as Core Data is concerned. A lot of it is already set up for us. ViewController is the out of the box ViewController that's going to be given to you via a storyboard which you're gonna see right here. We have Main.storyboard. Now storyboards are really a graphical way to lay out your application as far as the transitions between screens, and what type of segues and transitions happen when you click on a button, or do some sort of gesture or something like that. This allows you to lay it all out very visually, which is what we're gonna do and, and take advantage of in this course. And so, we're gonna get into this in a little bit more detail in the next couple of lessons. But just know that a storyboard is a way for you to graphically lay out your application, at least from a UI perspective, so you can see the flow of information and the flow of the user from one screen to the next. Now the previous ViewController.swift file is actually a default file that's given to you to represent the code behind this default screen we're given here. And we're actually gonna blow this away later on because we're gonna not use it, we're actually going to start with a different type of view controller, but we'll get to that. Then we have Images.xcassets, which is a relatively new mechanism that was introduced into Xcode to allow you to easily manage the assets or the images and icons within your application so you can work with a lot of different images and icons in here. And right now, by default, you're only given one, which is the AppIcon, which will be the default icon that's presented on the springboard of your iOS or your iPhone device. And you have, as you see, a couple different options here to support different resolutions and different screen sizes for different versions of iOS. As you can see here, iOS 5 and 6, 5 through 8, 7 and 8, and all sorts of different versions like that. So, that's something we're not gonna use a whole lot of, cuz we're not really overly concerned about the icon as far as this is concerned. We'll probably throw something in there later. But it's gonna be very simple so that we can just kind of see how it interacts with the actual system itself. Then we have this launch screen that's been put in here for us. Now, you'll see when we run our application that we're actually gonna see this, by default, pop up. That's kind of like our loading screen, and you may remember in previous versions of Xcode, or maybe when you were doing some other development, you would see like a default file in here, a default.png. And that would typically be loaded as your launch screen. Well, it's changed just a little bit here, but it's the same basic concept, and you can kinda play around with this. And add different text on here, or, you know, put some graphics on here, whatever. But this is basically gonna be your launch screen when you're creating this application or when you start to deploy it to either the simulator or an actual device. Now the xcdatamodel right here, this is what we're going to use to interact with or design our data model when it comes to using Core Data. And that database kind of functionality and we can start to build those objects out here. And we're gonna go into this in much more detail later on in the course but just know that it's there and this was created for us because we checked that use Core Data box. And then down at the bottom here, we have Supporting Files folder. Right now, all we have in here is our Info.plist. And this is the ever important kind of name value paired type file that's going to define a lot of properties which are basically kind of configuration type settings and, and information about your application as far as, you know, what levels of the applic, or what levels of iOS you're going to support and a number of different things like that. Now this is a very important file, it needs to be there. If it's not there, you're gonna have some, some building issues as well as some deployment to Apple issues if you cho, if you choose to actually go that far. So just know that it's there. And it's kind of used to create your application and define some, some high level properties about it. Now, the second folder here is SwiftReaderTests, which was created for us by default. We're not gonna do too much as far as creating tests, but this is where you can actually start to create some unit tests. And this was a nice feature that was kind of added into Xcode in the ability to create unit tests out of the box instead of having to actually install third party frameworks or something like that to actually start to write unit tests against your code. Because that's a very important task that most of us feel is something we have to address as software engineers. But, just know that this is here as well, and this also has a, an Info.plist specific to the SwiftReaderTest project in and of itself. And then finally, we have the Products folder, which is what's ultimately going to be built when we go through the process of building this application. It's going to create a SwiftReader.app file, which is ultimately what we're going to be using to deploy to our simulator so that we can start to see our application on a, either a device or the simulator. So we're not too worried about that either. We're gonna spend about 95 or 98% of our time in this SwiftReader folder adding and removing information from this particular folder. So, that's the basics of the project structure and in the next couple of lessons, we're gonna start to work on the storyboard and actually start to flush out with this particular application is going to look like, at least from a UI perspective.

Back to the top