Discover millions of ebooks, audiobooks, and so much more with a free trial

Only $11.99/month after trial. Cancel anytime.

Learn iOS Application Development: Take Your Mobile App Development Skills to the Next Level with Swift and Xcode (English Edition)
Learn iOS Application Development: Take Your Mobile App Development Skills to the Next Level with Swift and Xcode (English Edition)
Learn iOS Application Development: Take Your Mobile App Development Skills to the Next Level with Swift and Xcode (English Edition)
Ebook778 pages4 hours

Learn iOS Application Development: Take Your Mobile App Development Skills to the Next Level with Swift and Xcode (English Edition)

Rating: 0 out of 5 stars

()

Read preview

About this ebook

Grab this book if you want to make Apps for Apple’s iOS devices and that too efficiently like a skilled developer. This book covers the complete development of iOS applications, right from concepts of designing an application to adding machine learning capabilities in the applications.

You will learn and practice the App development environment with Xcode and Swift programming. Concepts like different types of views and UI components, data manipulations, animations, different iOS screen views, and integrating web services are covered in detail with examples. You will also learn the popular machine learning technology and fascinating features like Augmented Reality to be put into use in your app. You will learn to run automated application testing, use SwiftUI, and deploy applications on the network.
LanguageEnglish
Release dateJul 20, 2021
ISBN9789390684809
Learn iOS Application Development: Take Your Mobile App Development Skills to the Next Level with Swift and Xcode (English Edition)

Related to Learn iOS Application Development

Related ebooks

E-Commerce For You

View More

Related articles

Reviews for Learn iOS Application Development

Rating: 0 out of 5 stars
0 ratings

0 ratings0 reviews

What did you think?

Tap to rate

Review must be at least 10 words

    Book preview

    Learn iOS Application Development - Rudra S Misra

    CHAPTER 1

    iOS App Development Environment

    Introduction

    Xcode is an IDE from Apple to create apps for its ecosystem. With the Xcode IDE and Swift programming, you can create apps and services for iOS, ipadOS, macOS, tvOS, and watchOS. In this book, we will mainly focus on the iOS app development with Xcode and Swift. Here, we will focus on creating an iOS app development environment.

    Structure

    The following topics are covered in this chapter:

    Xcode

    Customized development environment

    Apple’s App Development Team

    Xcode Simulator

    Use the real iOS devices

    iOS architecture

    Objective

    In this chapter, you will learn how to properly set up the app development environment, so that you can make use of the technological advantages at the fullest during your app development learning and creation journey. We will also discuss the different developer programs from Apple, as well as the internal architecture of the iOS.

    Xcode

    Developing an app always demands a proper Software Development Kit (SDK). Xcode is the one and only best IDE that helps the developers to create and manage the apps for the Apple ecosystem. Yes, by using the Xcode, you can develop apps for the entire range of Apple's operating system like iOS, ipadOS, macOS, watchOS, and tvOS. With Xcode IDE and the SDKs of available platforms, you can design, write the code, run tests, publish to the App Store, as well as maintain the apps. That is why Xcode has been considered as a complete development tool for Apple. A typical Xcode environment may look like the following screenshot:

    Figure 1.1: Xcode with Swift

    Get your Xcode

    Xcode is freely available from your macOS’s App Store. To kick start the app development journey, you need to set up the development environment, considering the following pointers:

    Apple ID: The key to all Apple services is the Apple ID. So, you should have at least one Apple ID. If you don’t have one, do visit the following link and create one for yourself:

    https://appleid.apple.com/

    This website is even helpful in managing the Apple ID, if you have one, and want to change the settings or details:

    Figure 1.2: Apple ID website

    macOS: Xcode can be installed only on macOS. So, make sure that you have a computer with the latest macOS installed on it. For now (year 2020), the latest major released macOS is called Catalina, with version number 10.15. If you are running a macOS computer, click on the Apple menu and select About This Mac to know about the installed macOS. If required, you can update the OS and the security files from here by choosing the Software Update… option, as shown in the following screenshot:

    Figure 1.3: About this mac

    App Store: From the daily usage apps to the operating systems, App Store of macOS is a genuine place to download from. It is maintained by Apple with a highly proficient way to provide the best apps and services to its users. An App Store for macOS may look like the following screenshot:

    Figure 1.4: App Store for macOS

    Let’s find out the Xcode from the App Store. Open the App Store from macOS’s Dock. If you can’t see it or remove it from the Dock, open Finder, and then search for the App Store from the Application folder. You can directly search for the App Store using the Spotlight search.

    To grab the Xcode, you must sign-in to the App Store with your existing Apple ID. One can even be created from the App Store. As shown in the following screenshot, click on the Sign in option, which displays the following dialog box to enter your Apple ID credential:

    Figure 1.5: App Store Sign-in

    On the successful signing with Apple ID, you can search for the Xcode from the App Store. Once you get it, click on the Download button. If asked, do authenticate yourself with your Apple ID again. Now, the download has started for you. If you already got your Xcode downloaded into your computer, your App Store with Xcode may look like the following screenshot, where you have the OPEN option rather than the Download option:

    Figure 1.6: Xcode in App Store

    You can track the download progress from the Launchpad, available in the Dock. Once the download is completed, launch the Xcode. For the first launch, the Xcode demands for a few additional files to be downloaded to create the developed environment, by producing the following dialog box. Do click on the Install button and let the Xcode get those required files from the web:

    Figure 1.7: Xcode additional component install

    Welcome screen

    Once the additional downloads are completed, the Xcode will welcome you with its Welcome window. This window will give you the information about the Xcode, like the current version of the software, the latest development, and what kind of work you wanted to do with it. Also, it provides you with different options to start your development journey:

    Figure 1.8: Xcode Welcome

    In the preceding screenshot, you must be familiar with the Xcode’s Welcome screen. We marked certain areas with numbers to help you understand their needs, which are as follows:

    Shows the current version and the build number of Xcode.

    Get started with a playground: The typical coding only environment.

    Create a new Xcode project: The actual app development environment.

    Clone an existing project: Old or existing project migration environment.

    List of the latest activities, app development. Top most is the very recent task.

    Allows to browse the other projects that are not listed in Section 5.

    In the upcoming lessons, we will talk about these areas in detail.

    Customize development environment

    In the previous section, you have installed the Xcode and are in the Xcode’s welcome screen. Let’s move further and start working with Xcode. Be ready to create your very first app with Xcode and Swift.

    Create your first app

    The following step-by-step process will help you to create your very first app with Xcode:

    On the Welcome window, click on Create a new Xcode project.

    A template window will appear, as shown in the following screenshot, where you can pick the required templates and start working on them. This template window will give you an opportunity to pick any template from the entire Apple’s OSs series, like the iOS, watchOS, macOS, as well as the cross-platform with all kinds of development options for the Apple ecosystem:

    Figure 1.9: Xcode templates

    Let’s choose Single View App for the iOS platform for now, and click on Next:

    Figure 1.10: Product details

    In the preceding window, the basic details about your project are required. First, provide some meaningful Product Name, say MyFirstApp.

    For now, choose none from the Team option. Later, when we will talk about the Apple’s App Development Team, we will integrate the team and discuss further.

    Organization Name and Organization Identifier are the required fields, especially when you are trying to deploy or publish the app. We have a separate lesson on the Apple’s App Development Team, where we will talk about those fields. For now, you can fill any information over there. How about your name?

    Next, pick the programming Language as Swift. You may see another programming language called Objective C used earlier, before the Swift launched into the market.

    Make sure the User Interface section is the Storyboard, not the SwiftUI. We have a separate chapter for SwiftUI, where we talk about it in detail.

    You are now ready to launch the development environment. No need to tick any of the given options. Just click on the Next button.

    As shown in the following screenshot, Xcode asks to save your project into your computer’s hard disk. You are free to save it wherever you like. So, pick your location and click on the Create button:

    Figure 1.11: Create project

    Xcode environment

    Xcode launches the development environment for you. To make the developer’s life easy, Xcode provides an organized development environment. Let’s explore all these different areas of Xcode. In the following screenshot, we have marked certain areas with numbers to explain those areas:

    Figure 1.12: Xcode environment

    The explanations for the marked areas are as follows:

    Navigator: All the project-related files should be here. Even the external resources that are in use for this project, need to be dragged into this area. During the distribution, these files will be part of the app bundle. To organize the project files and resources, the Navigator provides the following options:

    Figure 1.13: Navigation options

    With the help of the preceding screenshot, from left to right, let's discover the different options of the Navigator:

    Show the Project navigator displays all the files and resources related to this project.

    Show the Source Control navigator displays all the changes made over the time period. This helps in the version controlling.

    Show the Symbol navigators displays all the classes and their functions used for this project.

    Show the Find navigator is a search tool. You can search anything related to this project using this search option.

    Show the Issue navigator displays all the warnings and errors related to this project.

    Show the Test navigator displays all the test cases related to this project.

    Show the Debug navigator displays the debug related information. For example, threads, CPU time, network usage, and so on.

    Show the Breakpoint navigator displays a list of breakpoints of the project.

    Show the Report navigator displays the test related reports, like debug, built, test cases result in report form.

    Toolbar: This section helps you to build and run your application, as well as manage the different viewing options for Xcode:

    Figure 1.14: Xcode Toolbar (L to R)

    The preceding screenshot shows all the available options in the Xcode’s toolbar. From left to right, they are as follows:

    The window controller to close, minimize, or full screen the Xcode window.

    The Play button to build and then run the project.

    The Stop button to exit from the running app.

    The Set the Active Scheme to pick the simulator or enrolled physical device for the app to run into. Click here to reveal the available simulator and activate the real devices available. The following screenshot shows some of that list:

    Figure 1.15: Active Schema options

    The Bar displays complete processes step-by-step while the app is running.

    The Library provides all the types of views, controls, snippets, and resources to design the UI.

    The Code Review provides detailed code changes information, if the source control is enabled for the project.

    The last three buttons help to toggle the visibility of the navigator, debug, and inspector areas of Xcode. Usually, if the color of these buttons is blue, then the corresponding area is visible, else hidden.

    Settings: The complete project related settings can be viewed or managed through this area. Many options are there and we slowly explore them as we go further.

    Inspectors: The settings for UI views and controls for your project can be found here. It also has multiple options to discover, which we will talk about soon.

    App design and coding environment

    On the Navigator, single-click on the main.storyboard file, which gives you, by default, an iPhone layout to design upon. This file is a collection of views, required for your app. Views are nothing but the face of the app. The users will interact with your app through the views. You will perform the User Interaction (UI) related design on a view. We will talk about the different types of views in the later chapters. Currently, the Storyboard holds only one view or default view, until added further. In the following toolbar and the preceding Storyboard’s view section, find the Adjust Editor Options icon, shown as follows:

    Figure 1.16: Adjust Editor Options

    Upon clicking, this icon will reveal different viewing options of the editor. From the given options, choose Assistant to make the changes in the editor window:

    Figure 1.17: Assistant option in Adjust Editor Options

    This Assistant splits the editor in such a way that you can see both the design and the corresponding coding files together at the same time. It has a few advantages. Among them, the main use of this Assistance mode for editors is to make a connection between the UI design and coding. In the Chapter 3, User Interface and Data Handling, we will discuss the connection in detail.

    The following screenshot is given to understand the different parts of the Xcode editors and their purposes:

    Figure 1.18: Development environment in Xcode

    From the preceding screenshot, we learn the following:

    Under the editor area, the design window helps you to make the UI design by using the UI views and controls.

    The Structure area shows all the views and controls in the form of a tree structure. This hierarchy helps to understand the design layout of the view. It even provides a dragging feature to make the changes to the design hierarchies.

    Under the editor area, the coding window helps you to write the logic to handle the user interaction behaviors.

    Under the debug area, the variable view helps to track the memory allocation and the value contained in them during run-time.

    Under the debug area, the console displays the print statements and error messages in details, if any, during run time.

    The Inspector area helps to customize the default design layout as per your requirements. It has many areas to explore:

    Figure 1.19: Inspector areas

    The preceding screenshot shows all the tabs of the Inspector area and their usages as follows, from left to right. Let’s understand its functioning:

    The File Inspector allows you to modify any Xcode files, used for the project.

    The History Inspector shows the modification timeline for the UI changes.

    The Help Inspector is the default help provider to know more about any UI components or classes or structures of libraries.

    The Class Inspector allows us to manage the corresponding classes from every view.

    The Attributes Inspector allows modification of the views and control’s properties.

    The Size Inspector deals with the size and alignments of any views and controls.

    The Connection Inspector helps to track the connections between the views and the corresponding coding files.

    Customize the environment

    Xcode allows us to modify the development environment, as per the developer’s convenience. Like the other Apps in macOS, Xcode has preferences, which allows the users to modify the settings of the Xcode.

    Let's launch the preferences for Xcode. As shown in the following screenshot, click on the Xcode menu from the top most menu bar, and then select the Preferences… option from there:

    Figure 1.20: Xcode Preferences

    The preferences window has many options, but here, we focus only on the environment customization related settings. Gradually, we will learn about the others as we progress further with this book:

    Figure 1.21: General tab of Xcode Preferences window

    From the General tab, as shown in the preceding screenshot, you can change the appearance of the Xcode like Dark or Light or just pick from the systems’ current mode. Also, you can set the settings like whether to see live error or not, whether to build the app even after the errors have occurred, change the parallelization settings, file lock, and so on.

    To change the coding windows appearances, go to the Fonts & Colors tab. Pick your choice from the inbuilt settings or you can create one for you:

    Figure 1.22: Fonts & Colors settings for Xcode

    To customize the text representation in the coding window, go to the Text Editing tab. Apart from the other settings, the line numbers are a useful setting to be enabled. This enables the line numbers beside every line of codes:

    Figure 1.23: Text Editor setting for Xcode

    Go back to the Xcode and observe all the customization changes. Now we can start the actual development related tasks.

    Apple’s App Development Team

    Apple provides various membership schemes for the developers. To be a developer and to publish your creation, you must enroll for at least one scheme.

    Membership schemes

    Apple is hosting the pages related to their offers on the Apple Developer Programs. Do visit the following page to understand the details and enroll for a program:

    https://developer.apple.com/support/compare-memberships/

    Apple has both, the paid and the free membership programs. Usually, the individual developers, who just started their journey in this field, can enroll for a FREE developer program with their Apple ID. It has limitations, for example, you can’t publish the app into any App Stores; you can’t use the code level support from Apple. But for learning purposes or the beginner level of journey, a developer account with an Apple ID is enough.

    Once you decide to pursue as a developer for the Apple platform, it’s a great idea to enroll for the Individual Apple Developer Program by paying $99 per annum. With this account, you can publish and distribute your app, as well as obtain plenty of support from Apple.

    If you want to start your own development venture or join a venture that is already in the app development field with Apple, then you must have the access to the Apple Developer Enterprise Program which costs $299 per annum. This account has the enterprise level support for the App Store. Even the account holders can create and distribute apps in their internal or private App Store for their employees and clients.

    Apple provides serious support programs to educational institutes. The iOS Developer University Program (iDUP) is one of them. With this kind of a developer membership, an education institute can enroll a good number of students every year toward app development for the Apple ecosystem. These apps can be published in the App Store, as well as in the internal distribution, but will always come under the FREE category. Monitory profile is not allowed with this program.

    FREE account

    If you enrolled for the free Developer Program with an Apple ID, try to login to your account from the Account tab given in the following link:

    https://developer.apple.com

    This portal gives you many resources to kick start your journey as a developer for the Apple ecosystem:

    Figure 1.24: Developer account

    The following are a few of the examples:

    You will have access to the framework and library-related documentation.

    You can download the Beta version of the development tools.

    You can connect with the developer forum.

    You can ask help on your doubts from the experts.

    You can even start learning the app development from scratch.

    Xcode simulator

    It is obvious that everyone can’t afford to buy all the different models of the iOS devices for app testing. So, the Xcode provides simulators of all available iOS device models that support the current iOS. This makes the life easy for the iOS app developers to test the design and functionalities across the iOS devices, without using real devices.

    There are a few limitations for using the simulators, which are as follows:

    It can’t use the telephonic services, like the phone call, SMS, and so on.

    It can’t use the iOS hardware functionalities, like the camera, microphone, and so on.

    It can’t use a few network services, push notification, MessageUI, and so on.

    For those cases, you must use the real iOS devices for testing. Although, most of the tasks can be tested in the simulators, but, before publishing, it is good to test your app on real devices for real feedback.

    From the Xcode’s toolbar, click on the Set the active schema to check out all the available iOS simulators. You can pick any from here to build and run your app. This option also provides the available real devices, if they are already enrolled with the Xcode. In the next lesson, we will talk about how to integrate and manage the real devices with Xcode:

    Figure 1.25: Active schemes for Xcode

    The simulators are also available for other Apple devices, like iPads, watch, and TV. Depending on your project settings, these simulators will be visible into the Xcode.

    The simulator is the mimic of a real device to run on a computer. It acts just like the real devices, except for a few limitations, which were mentioned earlier. Like the iOS devices, simulators build up in armv7 architecture. That’s why, in most scenarios, if your app works fine in the simulators, it can work fine in the real iOS devices too.

    Use of real iOS devices

    A simulator is good to start the app development. But considering the certain limitations and requirements of real-time testing, you must use the real iOS devices. Also, the iOS devices will be utilized

    Enjoying the preview?
    Page 1 of 1