Swift in 30 Days
eBook - ePub

Swift in 30 Days

Build iOS Apps by Learning Swift, Xcode, and SwiftUI in Just Four Weeks (English Edition)

Gaurang Ratnaparkhi

Share book
  1. English
  2. ePUB (mobile friendly)
  3. Available on iOS & Android
eBook - ePub

Swift in 30 Days

Build iOS Apps by Learning Swift, Xcode, and SwiftUI in Just Four Weeks (English Edition)

Gaurang Ratnaparkhi

Book details
Book preview
Table of contents
Citations

About This Book

Designing iOS mobile apps using simple Swift codes and libraries.

Key Features
? Combines the fundamentals of Swift and power-packed libraries, including SwiftUI.
? Includes graphical illustrations and step-by-step instructions on coding your first iOS application.
? Covers end-to-end iOS app development with code debugging and best practices.

Description
'Swift in 30 Days' teaches young graduates and coding applicants to enter the field of rapid development of applications through simplified, pragmatic, and quick programming learning without much theory.The book examines the basics of Swift programming, fundamental Swift building blocks, how to write syntax, constructs, define classes, arrays, model data with interfaces, and several examples of Swift programming. The book will help you to create the environment for app development, including tools and libraries like Xcode and SwiftUI. You will learn to work with Xcode and Swift libraries and finally make an independently developed Swift application. You will have access to design patterns and learn how to handle errors, debug, and work with protocols.By the end of this book, you will become a trusted Swift programmer and a successful iOS developer who will dive deeper into Apple's intelligent app programming challenge.

What you will learn
? Create an iOS app from scratch and learn fundamental Swift concepts such as operators and control flow.
? Create intuitive and intelligent user interfaces with an understanding of self-design and constraints.
? Recap OOP concepts and Swift protocol-based programming.
? Work with design patterns, write clean codes, and build expert tables and navigations.
? Work with Xcode and SwiftUI 2.0.

Who this book is for
This book is for students, graduates, and entry-level coders who want to learn iOS app development without prior Swift or mobile app development experience.

Table of Contents Week 1 (Beginner)
 1. Building Your First App
 2. Swift Programming Basics
 3. Auto Layout
 4. Types and Control Flow Week 2 (Intermediate)
 5. Optional Type and More
 6. Code Structuring Week 3 (Advanced)
 7. OOP in Swift
 8. Protocols and Delegates Week 4 (Bonus)
 9. Error handling and Debugging
 10. SwiftUI

About the Authors
Gaurang Ratnaparkhi has over a decade-long experience as a software developer with a specialization in iOS app development. Starting from Objective C and now to Swift 5.0, he has been able to work on a wide range of applications, from small calculators to apps in the aviation domain. His career highlight has been his position as a Team Lead for an iOS app in the restaurant domain. Followed by being a Tech lead for Cognizant IT solutions. He is a graduate from the University of Grenoble Alpes, France, and a certified Scrum Master. After moving to Xamarin and Windows development for a while, he returned to iOS development. He loves teaching and learning new languages. He is currently living in Toulouse, France. LinkedIn Profile: https://www.linkedin.com/in/gaurang-ratnaparkhi-0b47b81b/

Frequently asked questions

How do I cancel my subscription?
Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
Can/how do I download books?
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
What is the difference between the pricing plans?
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
What is Perlego?
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Do you support text-to-speech?
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Is Swift in 30 Days an online PDF/ePUB?
Yes, you can access Swift in 30 Days by Gaurang Ratnaparkhi in PDF and/or ePUB format, as well as other popular books in Informatik & Programmierung von Mobilgeräten. We have over one million books available in our catalogue for you to explore.

Information

Year
2021
ISBN
9789391030100

CHAPTER 1

Building Your First Application

Welcome to ‘Learning swift in 30 days’. During these 30 days, we will learn Swift and alongside learn to build basic iOS applications. You will familiarize yourself with the iOS application development environment. As we do not have enough time, let us jump right away into building our first application!

Structure

In this chapter, we will cover the following topics:
  • Setting up the environment
  • Creating your first project
  • Understanding Xcode
  • Running the application
  • Working of an application
  • Building the interface
  • Finding help

Objective

The objective of this chapter is to give you some initial confidence. We will do this by introducing you to the Xcode environment and then building a simple application. By the end of this chapter, you should be able to work easily with Xcode and create an iOS project.

Setting up the environment

One of the characteristic features of Apple is its bubble. You can enter this bubble and have all the Apple services. This holds true even for application development. If you want to develop an iOS or a macOS application, you will need a mac OS. Following are the steps to set up the environment for iOS application development:
  1. You need a mac system with a minimum OS version 10.15.
  2. Then, you need to create an Apple account. Go to https://appleid.apple.com/account as shown in Figure 1.1:
    Figure 1.1: Apple account Sign up page
  3. Complete the preceding steps to create your app store account. They may ask for credit card details. Don’t worry you won’t be charged.
  4. Once your app store account is set up, go to the Apple App Store by clicking on the icon in Applications as shown in Figure 1.2:
    Figure 1.2: App Store icon
  5. Then, type “Xcode” in the search box. Here, you will need the Apple account created above to download the latest version of Xcode. Make sure you have at least 20 GB of free space on your Mac.
  6. Once installed, you should be able to see the Xcode icon (Figure 1.3) in your applications.
  7. We will build simple applications, so you won’t need an iPhone. Xcode comes with a simulator.
    Figure 1.3: Xcode icon

Creating your first project

We will create our first project. This will help you understand the different elements that go into making of a project. The end product is a simple application with an image. No complicated logic or even coding! You will even understand the Xcode development environment and after reading this chapter, you will be easily able to navigate through Xcode.
Let us create our brand new Xcode project:
  1. Click on the Xcode icon. You should be able to see a window similar to Figure 1.4. The version (red box) might be different from yours but a minimum of 11.x is recommended. Here, we choose a starting template for our iOS. We are new developers, so let us stick to the simplest form, Single View App.
    Figure 1.4: Xcode launch window
  2. Next, click on the second option (green box) to start creating our first iOS project. You should then be able to see a window like the one in Figure 1.5:
    Figure 1.5: Template selection for new project
    The other templates are up to you to explore. But the single view application is the most basic and customizable template available.
  3. Once you click on “Next”, you will see a window as shown in Figure 1.6:
    Figure 1.6: Choose options for your new project
    Before you create a new project, we have to specify some details. So, let us understand what details we need to fill in:
    • Product Name: This is the name of our application. This is a demo application so it is not so important right now. But in future when you develop applications for the App Store, this name is very important. Let us name our application “MyFirstApp”.
    • Team/Organisation Name: This can be “None”. For real-world applications, this option is often the Team account of your company and the organisation name is your company name. Well, right now you are your own boss so go ahead and put your name. If you have an Apple developer account, you can link it and then you can see your own name under teams.
    • Organisation/Bundle Identifier: This is a unique identifier for the application. It is the web address equivalent for an application. You can see the required format in tiny grey letters below the box. You just have to put the first two parts: com.yourCompanyName.
    • Interface: THIS IS IMPORTANT. Set this to Storyboard. We will make SwiftUI applications later. But for now, we will work with Storyboards.
    • Language: Swift! If you want to choose Objective C, this is the wrong book for you.
  4. Once done, your window will look something like the one in Figure 1.7. Now, click on “Next” and choose where you want to save the project. That’s it! We have created our first iOS Application project. Congratulations!!
    Figure 1.7: Filled options for new project

Understanding Xcode

So what is Xcode? Xcode is an Integrated Development Environment (IDE) by Apple. It has the complete developer toolset to develop software for macOS, Apple watch, Apple TV, iPhone, and iPad. It is the ONLY way to develop applications for the Apple environment. This makes it our only option and we must know it well.
Our new project is ready and by now, you should see a window like the one in Figure 1.8. What you are looking at is the project settings. These are quite self-explanatory, but diving deep into the project settings is not our aim. Next, click on the file “App Delegate” which is in the pane of the left-hand side of the screen.
Figure 1.8: New project landing
Now, you will see Xcode the way we will be using it. So, let us take a small tour of this environment. Look at Figure 1.8.1. This shows the Xcode screen for version 11.x:
Figure 1.8.1: Different panes in Xcode 11
Figure 1.8.2 shows the Xcode screen for version 12.x. There are small differences which we will discuss:
Figure 1.8.2: Different panes in Xcode 12
You can see the different areas in the Xcode. You can hide...

Table of contents