The Pros and Cons of Building an iOS App with Swift

Paweł Kozielecki

Apr 1, 2021 • 8 min read

Swift may be considered a mere child in the programming world, but it’s becoming a popular language for businesses wanting to build an iOS app.

Simple to use and easy to read, Swift has changed the way iOS apps are developed and is making what wasn’t possible.

Before the advent of Swift, apps were primarily created with Objective-C, which was time-consuming and difficult. With Swift, the benefits it brings for app development are countless. Speed, security, user experience, and maintenance are just a few examples. Let’s consider these as we turn our attention to the use of the Swift programming language in iOS app development.

What is Swift? A brief overview

Created in 2014 by Apple, Swift is a programming language for iOS, iPadOS, macOS, tvOS, watchOS, and Linux applications. It wasn’t until 2015, though, that Apple decided to open source the code to boost greater adoption. Now, the Apple App Store has 1.96 million apps available to download, which are partially written in Swift. These include Airbnb, Facebook, LinkedIn, Lyft, Slack, and Uber.

Previously written in Objective-C, a programming language that dates back to the 1980s, Lyft is one example of an app that switched to Swift. The original version of Lyft had grown to 75,000 lines of code, but by moving to Swift the company recreated the app with the same functionality with less than a third of that.

Within a few years, the community has moved from the outdated Objective-C language to a modern, backward-compatible programming language that is easy to learn and read. For businesses seeking a programming language to develop an app, here are the pros and cons of Swift.

The advantages of Swift

Often referred to as “Objective-C, without the C,” Swift has many benefits compared to its predecessor.

It’s fast

The official Apple website claims that Swift is 2.6 times faster than Objective-C, helping with cost-saving measures. It’s also easier to read and write. As noted above with the Lyft example, businesses can develop an iOS app using Swift quickly as it requires much less code than other languages.

Closeup of hands of young man in checkered shirt using mobile phone while his partners arguing

It’s safe

Another of Swift’s strengths is its safety. It’s created to be a type-safe and memory-safe programming language. Type-safeness points to the language preventing any type errors. Memory-safe means that it avoids vulnerabilities linked to uninitialized pointers, which could lead to a program crashing. With a shorter feedback loop (this is when outputs are fed back as inputs, which determines the cause and effect of that loop), developers can see any code errors, reducing the time spent on debugging and removing the risk of low quality code.

Interoperable with Objective-C

By being compatible with Objective-C, projects can be written in either language. This is especially useful for big projects that are being updated as more features are added with Swift, which are then placed into Objective-C’s codebase.

Low maintenance

Once an app is built with Swift it’s easy to maintain. Compared to Objective-C, which is managed in two separate files, Swift combines the Objective-C header (.m) and implementation files (.h) into a single program (.swift) file. One thing to note is that Swift has dependencies. Whereas, on MacOS, Swift is already installed and ready to go, on Linux to install Swift you need to install certain dependencies, like Python, first.

Better user experience

Apps developed with Swift require less time to install and less on-device memory, providing a better app experience for users.

Effective memory management

Swift uses a solution called Automatic Reference Counting (ARC) that builds upon its ObjectiveC predecessor. The ARC determines which class instances are not being used and gets rid of them for developers. This gives developers more time to focus on the app’s performance without reducing its CPU or memory allocation.

ABI stability

Application Binary Interface (ABI) is a binary equivalent to an Application Programming Interface (API) for Swift. According to Swift, while ABI stability is a significant achievement for any programming language, “the ultimate benefit to the Swift ecosystem was to enable binary compatibility for apps and libraries.” In effect, the ABI allows code compiled using different versions of Swift, and even ObjectiveC, to communicate.

Use of optionals

Optionals are a programming concept that enables developers to prevent app crashes while ensuring clean code is maintained across the application. Think of it as a wrapper type, which wraps the value inside. An optional can either contain something or be empty. To know for sure, optionals need to be unwrapped, and if done properly won’t cause crashes.

The disadvantages of Swift

While Swift has been designed to make maintaining and writing app code easier for the developer, there are a few disadvantages to consider as well.

Swift is still a new language

Compared to Objective-C, which has been around since the 1980’s, Swift is a newcomer, having been created in 2014. This means it might suffer from growing pains. Despite recent updates with ABI Stability and backward compatibility, Swift is limited on tools and libraries.

Netguru-Biuro-2018-6078 _HD

Binary compatibility doesn’t always work

Even though ABI Stability is an advantage of Swift 5.1, code compiled with different versions of Swift can come into problems. When developers were primarily using Objective-C, code could have been compiled into a static library and introduced into a project as a dependency. Before the introduction of Swift’s ABI, it was not possible to create static libraries in Swift. While that’s now possible, there are issues implementing those dependencies into a project.

It’s not a reflective language

Compared to programming languages such as Java or Kotlin, Swift is not a reflective language. Instead, it offers an alternative: a Mirror functionality. With this, Swift can take an object and “self-describe” it, but it can’t manipulate it from within. If reflection was available in Swift, it would automatically inject dependencies, but it’s believed this would be difficult to achieve.

Small talent pool

This is another minor disadvantage, but it needs bringing up regardless. While Swift’s community is growing fast, it is still relatively small compared to other programming languages. A 2019 developer survey from StackOverflow found that only 6.6% of over 87,000 respondents use Swift.

Learning a new language

While it’s an easy language to learn, it still requires time to understand Swift, which some projects may not have. If a business can delay the release of their app until team members are comfortable with Swift, this will be a good move in the long-term as Apple continues to invest in its development.

Is Swift the future for iOS development?

Despite its young age, Swift is becoming a widely used programming language for iOS development. A few of the companies that have already chosen Swift are Eventbrite, Kickstarter, LinkedIn, Twitter, and Whatsapp. Even though there are still teething issues to solve, Swift is turning into a mature language that could, eventually, see it displacing Objective-C as the go-to language for developing iOS apps.

In the long term, Swift will help businesses fill the mobile app gap. It’s a fast language that is easy to understand, it’s becoming a preferred choice for developers. As it’s an open-source platform it has a substantial community behind it with contributions from anyone who wishes to take part. For businesses looking to make the switch to a language with the least amount of effort, Swift will continue to be a key component for app development in the future. If you’re looking for an opportunity to learn Swift, send us a message.

More posts by this author

Paweł Kozielecki

iOS Tech Lead at Netguru
New call-to-action