Build a basic IOS app using Swift

10 May
2021

An introduction to using X-Code to build an IOS app. This tutorial focuses on getting to know the X-code and swift interface.

This is a video tutorial where you can learn how to make a simple IOS/MacOS/WatchOS/IpadOS app using Swift. The video goes through a full simple app build from installing the software to actually using it. The article below serves as a general guide to swift and it's basics.

What is Swift?

Swift is a robust and intuitive programming language created by Apple for building apps for iOS, Mac, Apple TV, and Apple Watch. It’s designed to give developers more freedom than ever. Swift is easy to use and open source, so anyone with an idea can create something incredible.

Swift is a fast and efficient language that provides real-time feedback and can be seamlessly incorporated into existing Objective-C code. So developers are able to write safer, more reliable code, save time, and create even richer app experiences.

Swift is free and open source, and it’s available to a wide audience of developers, educators, and students under the Apache 2.0 open source license. We’re providing binaries for macOS and Linux that can compile code for iOS, macOS, watchOS, tvOS, and Linux. And to help Swift grow into an even more powerful language, we created a community where users can contribute directly to the Swift source code.

What is needed to get started?

To become a proficient coder in swift you really need three things:

  • A computer capable of running a Swift editor such as any apple Mac, Macbook or iPad
  • The latest update XCode (downlaoded from the app store for free)
  • Enthusiasm to experiment and play with the code!

What is XCode?

Xcode consists of a suite of tools that developers use to build apps for Apple platforms. Use Xcode to manage your entire development workflow—from creating your app to testing, optimizing, and submitting it to the App Store.

General guide for creating an XCode project

1. Prepare Configuration Information

Before you create a project, collect the information that Xcode needs to identify your app and you as a developer:

  • Product name. The name of your app as it will appear in the App Store and appear on a device when installed. The product name must be at least 2 characters and no more than 255 bytes, and should be similar to the app name that you enter later in App Store Connect.
  • Organization identifier. A reverse DNS string that uniquely identifies your organization. If you don’t have a company identifier, use com.example. followed by your organization name, and replace it before you distribute your app.
  • Organization name. The name that appears in boilerplate text throughout your project folder. For example, the source and header file copyright strings contain the organization name. The organization name in your project isn’t the same as the organization name that appears in the App Store.

2. Create a Project

Launch Xcode, then click “Create a new Xcode project” in the Welcome to Xcode window or choose File > New > Project. In the sheet that appears, select the target operating system or platform and a template under Application. In the following sheets, fill out the forms and choose options to configure your project.

Creating a project in XCode. Screenshot
source: Xcode. (n.d.). Retrieved August 19, 2021, from https://developer.apple.com/documentation/xcode

You must provide a product name and organization identifier because they are used to create the bundle identifier that identifies your app throughout the system. Also enter an organization name. If you don’t belong to an organization, enter your name.

Entering project name and details.
Source: Xcode. (n.d.). Retrieved August 19, 2021, from https://developer.apple.com/documentation/xcode

To develop for all platforms and see an interactive preview of your layout, choose SwiftUI or Storyboard as the user interface before you click Next on this sheet. Oisin prefers the Storyboard layout.

Managing files in the main window

When you create a project or open an existing project, the main window appears, showing the necessary files and resources for developing your app.

You can access different parts of your project from the navigator area in the main window. Use the project navigator to select files you want to edit in the editor area. For example, when you select a Swift file in the project navigator, the file opens in the source editor, where you can modify the code and set breakpoints.

The Main Window.
Source: Xcode. (n.d.). Retrieved August 19, 2021, from https://developer.apple.com/documentation/xcode

Details about the selected file also appear in the inspector area on the right. In the inspector area, you can select the Attributes inspector to edit properties of a file or user interface element. If you want to hide the inspector to make more room for the editor, click the “Hide or show the Inspectors” button in the upper-right corner of the toolbar.

You use the toolbar to build and run your app on a simulated or real device. For iOS apps, choose the app target and a simulator or device from the run destination menu in the toolbar, then click the Run button.

For macOS apps, just click the Run button. When your app launches, the debug area opens, where you can control the execution of your app and inspect variables. When the app stops at the breakpoint, use the controls in the debug area to step through the code or continue execution. When you are done running the app, click the Stop button in the toolbar.

To change properties you entered when creating your project, select the project name in the project navigator that appears at the top, then the project editor opens in the editor area. Most of the properties you entered appear on the General pane of the project editor.

Resources

XCode website

XCode guides and documentation (Apple)

References

Swift - Apple. (n.d.). Retrieved August 19, 2021, from https://www.apple.com/swift/

No items found.