This content is part of the Essential Guide: The complete Apple iOS guide for IT administrators

Developers reap benefits of iOS app modules with Swift

Many developers recognize the benefits of app modularization. Historically, it's been difficult to begin the process, but now changes from Apple provide more opportunity.

BOSTON -- Modularization is one of the basic best practices of app development, but recent updates from Apple put it even higher on the priority list for many iOS developers.

Modularization is the process of breaking down an app into smaller, more digestible components. App modules are often based on particular functions; for example, an authentication module supports the authentication process, a login module supports the login process and so on. Here at this week's SwiftFest event focused on Apple's Swift programming language, developers discussed their reasons for breaking mobile applications into app modules and how they approach the process.

Modularization offers a variety of benefits to an app development team. For example, it generates a stronger sense of code ownership, which can cut down on time wasted during the development process. Modularization can also allow developers to track quality code and bugs more easily.

Cut confusion, allow scalability

Brad Smith, a senior iOS engineer at Wayfair, an e-commerce company based in Boston, is in the process of beginning to break down its app into app modules. Wayfair has a large team of 40 developers, which created confusion over code ownership during the app development process. The goal of modularization is to lower build times, eliminate bottlenecks and increase productivity, Smith said.

If you sound like a crazy person when you're explaining your code to someone else, that's a sign that you need to be more organized.
Alvin AndinoiOS software developer, Intrepid Pursuits

"If you sound like a crazy person when you're explaining your code to someone else, that's a sign that you need to be more organized," said Alvin Andino, an iOS software developer at Intrepid Pursuits, a mobile development firm in Cambridge, Mass.

Modularization through Swift would clear up some of that confusion because Swift offers well-defined access controls that can limit developers to work on their own modules. Andino works in a team of six, but his team still deals with issues that Wayfair's larger group deals with, such as code ownership. Breaking the app into app modules would help clarify the onboarding process for new developers, Andino said.

Scalability was one of the main reasons for The Washington Post's development team to modularize, said Arthur Sabintsev, a lead iOS developer for the newspaper. After Jeff Bezos, the founder and CEO of Amazon, acquired The Washington Post in 2013, the company pivoted to also operate a software as a service (SaaS) platform called Arc Publishing that handles content management for other publishers such as The Boston Globe and Los Angeles Times.

"To scale at that level, we needed to break apart our code, which was tightly coupled to how the Post operates," Sabintsev said. "The best way was to break everything apart into single pieces and then add these extra features [that our clients requested]."

Prior to modularization, the SaaS platform only supported Adobe Omniture for analytics. But during the modularization process, the team built a translation layer to take the raw data and convert it in a way that other analytics platforms such as Google's Firebase and Snowplow could understand.

The process of modularization

To break down an app into app modules, the development team must be able to share the code. There are two main ways to achieve that in iOS: static libraries and dynamic frameworks. Developers can opt to use one or the other, or a mixture of both.

Static libraries allow developers to distribute and share source files to then make a copy of the code and link it into the code binary. In 2017, Swift introduced support for static libraries in Xcode 9.0, Apple's development environment, making it possible for iOS developers to modularize in Swift. But developers can't attach resource files to static libraries, and there is a greater risk of creating duplicate symbols.

Dynamic frameworks, on the other hand, are more flexible than static libraries. A dynamic framework is essentially a dynamic library that is embedded in a bundle. Apple made dynamic frameworks available as of iOS 8. The downside of dynamic frameworks, however, is that they can result in a longer app launch time.

The evolution of modularized apps

Although breaking an app into app modules is a basic tenet of development, there are a few recent changes that have made the process more accessible for developers.

First, there was Apple's support for dynamic frameworks in iOS 8 and for static libraries in Swift. Another change is Apple's introduction of a variety of OSes, including TV OS and Watch OS, said Calvin Chestnut, an iOS developer at Rue La La, an e-commerce company in Boston. Each OS has different requirements and capabilities; for example, developers can't use table views on Watch OS, but they can on iOS and TV OS. But breaking the code down into app modules allows developers to more easily share the code between different targets, Chestnut said.

The ability to port iOS apps to macOS with a universal framework -- announced at Apple's 2018 Worldwide Developers Conference -- will make that process even easier.

"It's the dream of every developer," said Giorgio Natili, a software development manager at Amazon. "It's a really good sign of [Apple] listening to the community."

Other developers don't believe that Apple's different OSes are conducive to modularization. Developers need to be able to create crisper, cleaner, access-controlled interfaces with shared libraries to modularize effectively, said Brian Arnold, an engineering manager at MathWorks Inc., a software company in Natick, Mass. Swift, however, is primed for modularization because it allows developers to keep collections of symbols separate from each other, he said.

"Apple has made it easier," Arnold said in an email. "But [frameworks and extensions] are not sufficient to enable companies sharing code in multiple apps to further increase modularity, except in a very limited way."

Dig Deeper on Mobile infrastructure

Search Networking
Search Unified Communications
Search Security
Close