Introduction to Xcode
Published March 09, 2022Xcode is the default IDE developed by Apple INC. for writing swift code , it is an essential tool to every iOS developer that is free on the app store in this article , you will be guided through the basics of Xcode and some shortcuts you can use to make your iOS developer journey easier.
This is a Pop-Up you will get anytime Xcode is launched , let’s go through some of the things you see and explain them .
-
Over to the top left , you’ll see the huge Xcode logo with a text that says “Welcome to Xcode ”, below that you can see your version number, this things aren’t really as important in iOS development .
-
Below your version number , there is a page sheet with a plus sign in it that says “ Create a new Xcode Project ”, this button takes you to another Pop-Up that gives you some more options you need to chose to start creating your iOS project .
-
Below that , there is another button with two page sheets that says “Clone an existing project ” , assuming there is a Git respiratory you want to wok from , you tap this button .
-
And the final thing on our list is the button with a picture of a folder that says “Open a project or file” , If you have a downloaded Xcode file on your Mac you will like to open , you can use this button to open it .
To the right part of the screen , this is where all your projects will be saved I have one or two projects saved there, so you can see how it would look like .
Xcode.
This is the next Pop-Up I was talking about earlier , this Pop-Up basically just gives you more options to pick from and is the last Pop-Up , there are two more Pop-Up you’ll see before getting to write actual code .
Like before, let’s go through what we see on the screen.
-
At the top , there is a text that says “Chose a template for your project ”, I think that should b enough to let you know this Pop-Up will be used for making a little customizations for your application, here you will tell Xcode things like the platform you will like to build on whether it’s iOS , macOS, watchOS, tvOS ,DriveKit , other or Multiplatform.
-
Below that , you will see some buttons , this buttons just simply give you the option to pick that type of application you will like to create some of the options include :
-
App : This is used to build a regular iOS application.
-
Document App :
-
Game : to build iOS games using SpriteKit (A package developed by Apple to build games).
-
Augmented reality App : to build a n application that supports/uses augmented reality.
-
Swift Playground App : this is mostly used to build simple programs using swift
-
Sticker Pack App : This is used to build sticker packs that can be used in your messaging apps like iMessage.
-
iMessage App : This is used to create games /applications that can be used in iMessage , a very good example is Game Pigeon.
-
Safari Extension App : This is used to create applications that can be used while running safari
Under all these , there is another section with a header that says “ FrameWorks & Library”
There , there are some buttons that just show some frameworks and libraries that you will use in advanced iOS development
This is the second to the last Pop-Up you’ll meet before writing actual code , what this Pop-Up is meant for basically , is to add some basic items you’ll need like a product name , Bundle identifier , team and so on , let’s take a quick look at the items on the Pop-Up,
-
Product name : This is the space where you will type the display name or the name you want to call your project
-
Team : this is associated with your Apple ID and comes up when you have Xcode installed
-
Organization Identifier : This is usually formed by giving the reverse of your website
-
Bundle Identifier : Xcode creates this as you type in your product name .
-
Interface : There are only two options in the interface section SwiftUI and Uikit .
SwiftUI : This is the latest user interface builder and the one that we will be working with on our final project .
UIKIT : This is also a user interface builder developed by Apple, it has been around for a longer while than SwiftUi .
SwiftUI or UIKIT
Most iOS developer gurus suggest you learn Uikit if you are in search of a job , but I prefer to learn both because apart from the fact that SwiftUI is the future of iOS development , big companies like Apple Inc. are moving to SwiftUI.
-
Language : In this section , there are two options ,earlier in this article , it was stated there are only two languages you can use in iOS development , Swift and Objective-C , here is
-
where Xcode gives you the chance to choose between those two languages .
//The section for using core data and include tests are things you don’t need yet.
After completing all these steps there is just one more thing you need to do before you get to write actual code , and that is saving your file .
Finally , it’s time to write some actual code and get Into Xcode.
This is the screen you’ll get once you have successfully saved your file , this is the screen where you will write your code , over to the right part of the screen at he extreme end , we have file managers , Xcode will create some files for you automatically and we can see them there , already saved and ready , also whatever file you decide to create , will be added there .
How to create a new file : Just like most applications on the Mac , it only takes two buttons to create a new file in Xcode , Command + N , by holding down command and at the same time pressing N , you will see a Pop-Up that gives you options of different files you will like to create.
Xcode is the default IDE developed by Apple INC. for writing swift code , it is an essential tool to every iOS developer and in this article , you will be guided through the basics of Xcode and some shortcuts you can use to make your iOS developer journey easier.
You would see this once you have held Command and at the same time press N , there are different types of files you can create like a new SwiftUI file , Cocoatouch file C++ file , Swift file and many more , but for now , we will focus in the SwiftUI file , Just like before , when you tap the SwiftUIView , you’ll se a Pop-up that will allow you to provide a name for the file and another one to make sure you have everything ready .
Back to the main page then ,
n The center of the page is divided into two parts , on one side there are some code and on the other there is a canvas.
Canvas : This is a simulator like thing in Xcode that you get when you are working with SwiftUi ,the main function of this simulator is that it updates as you update your code in real time .
Now , we are left with the main code section , like Xcode has created some files for us , it also wrote some code for us to help us get started , it feels like tradition to get the “hello world “ text printed out for you in every programming language you use on Xcode , you can give it a try .
We have been through the basic things In Xcode , now we write our first sets of code .
Apple has provided us with two frameworks for building iOS applications , SwiftUI and Uikit , I have said little about them earlier , to actually write an iOS application of your own you have to know the swift programming language and one or both of the two frameworks , for now we will be talking about the views and view controllers , this is mostly applicable to Uikit .
Views & View Controllers.
To begin with , what is a view controller ?
Because we are using Uikit , it is best we call it UI view controller , the Ui view controller is an object that manages the view hierarchy of an application developed using Uikit . It controls the shared behavior of all ViewControllers in the app.
Storyboard & interface builder
One of the important things in creating an application is the user interface and in Uikit one of the ways to create that is called storyboard , Storyboard is a page in Xcode that replicates the iPhone’s screen to allow you to add items to the screen. Creating it is also an easy task , after opening your Xcode project , you go down to your file manager , you’ll see a file that states main, click it and you get the screen below
//This is a storyboard
Now ,let’s take our time to get into views & View controllers
Article Contributed By :
|
|
|
|
216 Views |