Page
1
Extreme Mobile Innovative Techniques for Crafting Customizable Mobile Apps Using iOS Frameworks — Charlie Cocchiaro
Page
2
Extreme Mobile Innovative Techniques for Crafting Customizable Mobile Apps Using iOS Frameworks Charlie Cocchiaro
Page
3
Extreme Mobile: Innovative Techniques for Crafting Customizable Mobile Apps Using iOS Frameworks ISBN-13 (pbk): 979-8-8688-2322-0 ISBN-13 (electronic): 979-8-8688-2323-7 https://doi.org/10.1007/979-8-8688-2323-7 Copyright © 2026 by Charlie Cocchiaro This work, including sample software, is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed. Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights. While the advice and information in this book are believed to be true and accurate at the date of publication, neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or omissions that may be made. The publisher makes no warranty, express or implied, with respect to the material contained herein. Managing Director, Apress Media LLC: Welmoed Spahr Acquisitions Editor: Miriam Haidara Editorial Assistant: Jessica Vakili Cover designed by eStudioCalamar Cover image designed by Charlie Cocchiaro Distributed to the book trade worldwide by Springer Science+Business Media New York, 1 New York Plaza, New York, NY 10004. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@springer-sbm.com, or visit www.springeronline.com. Apress Media, LLC is a Delaware LLC and the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation. For information on translations, please e-mail booktranslations@springernature.com; for reprint, paperback, or audio rights, please e-mail bookpermissions@springernature.com. Apress titles may be purchased in bulk for academic, corporate, or promotional use. eBook versions and licenses are also available for most titles. For more information, reference our Print and eBook Bulk Sales web page at http://www.apress.com/bulk-sales. Any source code or other supplementary material referenced by the author in this book is available to readers on GitHub (https://github.com/Apress/Extreme-Mobile). For more detailed information, please visit https://www.apress.com/gp/services/source-code. If disposing of this product, please recycle the paper Charlie Cocchiaro Chelmsford, MA, USA
Page
4
To my wife Elaine, for inspiring me to do great things. To my parents Sam and Jean, for the many sacrifices they made so I could chase my dreams. To my brother Carl, for pushing me to strive for perfection. To my sister Celia and brother Chris, for their unwavering support.
Page
5
(This page has no text content)
Page
6
(This page has no text content)
Page
7
(This page has no text content)
Page
8
(This page has no text content)
Page
9
ix About the Author With a career spanning many decades, Charlie Cocchiaro has made lasting contributions to the software industry as both a technology leader and software architect. From his early days writing machine-level code on punch cards, he has brought to market dozens of successful mobile apps for startups, established corporations, and his own enterprise, Graphixware. As Director of Software Engineering at Constant Contact, he led large-scale engineering teams across email, SMS, and mobile marketing, driving the development of innovative platforms that expanded the company’s digital marketing impact. Charlie holds a US patent as the inventor of the Wang Labs Graphics Enhancer drawing application. His imaging application, PerfectImage, received the prestigious JavaOne Duke’s Choice Award from Oracle (Sun Microsystems) for best imaging application worldwide. And his social media mobile application, Whole Lotta Likes, ranked #11 in the fiercely competitive Social Networking category. His portfolio features more than 20 released apps on the Apple App Store, including music apps ScratchTones, TrueTones, and Sheet Music Direct. A lifelong musician, Charlie is also a former professional rock guitarist and songwriter who performed extensively throughout New England with hard rock bands he co-founded with his twin brother, Carl. While endorsed by Jackson Guitars and SIT Strings, the Cocchiaro brothers released their debut album Cocchiaro, combining musical expertise and technical skill, a foundation that continues to drive Charlie’s work at the intersection of music and technology. LinkedIn: https://www.linkedin.com/in/charlescocchiaro/ Graphixware: https://graphixware.com/ Cocchiaro: https://cocchiaro.com/
Page
10
xi About the Technical Reviewer Carl Cocchiaro is a Quality Engineering Leader in the Test Automation field with 25+ years of expertise as a Software Consultant and Architect, currently residing in Boston, MA USA. He is the author of several technical books including Selenium Framework Design in Data-Driven Testing and Learn Selenium, both published by Packt Publishing, LTD. Selenium Rockstar is his latest book, which is a Comprehensive Migration Guide to the latest Selenium and Appium Technologies.
Page
11
xiii Preface The motivation for writing this book stemmed from the belief that software should be developed to maximize efforts, minimize redundancy, and promote innovation. Deliberate attention was given to avoid providing excessive detail for some technologies and topics and to maintain a concentrated focus on techniques and technologies directly applicable to iOS Frameworks. It’s important to recognize that subjects like testing, branding, and internationalization are substantial enough to warrant their own comprehensive books. Readers are strongly encouraged to complete every chapter of this book, with particular emphasis on actively engaging in the process of writing the code outlined within each chapter.
Page
12
xv Introduction The objective of this book is to demonstrate practical techniques for designing and developing reusable, configurable, brandable, and localizable iOS mobile software. This will be achieved by leveraging iOS Frameworks to build commercial-quality mobile applications efficiently and systematically. Designing and developing these types of reusable, modular solutions offers numerous advantages. Common functionality used across an engineering organization can be reused in multiple applications and extended as needed, reducing development time and improving consistency. Revenue opportunities can be enhanced by offering feature sets through pricing tiers and In-App Purchases. New functionality can be added dynamically with minimal effort. Centralized assets and styles make rebranding simple and straightforward. Furthermore, internationalization and localization can be incorporated without extensive re-engineering, enabling apps to reach a global audience quickly. This book is intended for intermediate software developers who have a foundational understanding of Xcode, iOS SDK, Swift, Storyboards, and SwiftUI. The book begins with core concepts for developing reusable software using iOS Frameworks and gradually builds complexity in a clear, step-by-step manner. Readers will explore Swift Protocols, the Model-View-ViewModel (MVVM) design pattern, local and remote service requests, Dependency Injection, Combine, SwiftData, Swift Testing, Storyboards, and SwiftUI. Techniques for dynamically integrating iOS Frameworks into applications are also covered. By the conclusion of this book, readers will have developed two distinct applications using the same frameworks, demonstrating the power and flexibility of reusable, modular iOS software without needing to modify underlying code.
Page
13
1 © Charlie Cocchiaro 2026 C. Cocchiaro, Extreme Mobile, https://doi.org/10.1007/979-8-8688-2323-7_1 CHAPTER 1 Building the Foundations of Modular Framework Design Designing the SettingsFW Framework Swift protocols will be introduced as the first means of supporting software modularization in mobile apps. A Swift protocol is a blueprint or interface that defines a set of methods, properties, and requirements that a class, structure, or enumeration can adopt. It provides a way to establish a contract between different types, allowing them to communicate and interact with each other in a consistent manner. Protocols in Swift are used to define common behavior or functionality that can be shared among multiple types, enabling code reuse and promoting modularity. By adopting a protocol, a type guarantees it will implement the required methods and properties defined by the protocol, thereby ensuring a common set of capabilities and enabling polymorphism. You can find additional details regarding Swift protocols1 at Swift.org. When designing iOS Frameworks, it’s critical to strive for decoupling software components. This goal ensures that modifications made to one component will have minimal impact on others. When components are tightly coupled, where strong dependencies exist, maintaining the system becomes arduous and time-consuming. Swift protocols can help reduce coupling by abstracting implementation details and minimizing the need for widespread changes across the framework and apps that integrate it. This can facilitate a more streamlined and manageable development process. 1 Swift Protocols: https://docs.swift.org/swift-book/documentation/the-swift- programming-language/protocols/
Page
14
2 In this chapter, we’ll design an iOS Framework using a Swift protocol. By the end, you’ll have created your first iOS Framework and successfully integrated it into a mobile app, giving you hands-on experience with modular, reusable code. Creating an iOS Framework Xcode provides a project template called Framework, located under the Frameworks & Libraries group, for creating an iOS Framework. Originally called Cocoa Touch Framework, the Framework template will provide a default set of files for the project. You’ll add to those as you progress through the chapter. Let’s get started! Choose a template for your new project: 1. Launch Xcode 2. Select Create New project 3. Select the Framework template under the Framework & Library group (Figure 1-1) 4. Select Next Chapter 1 Building the Foundations oF Modular FraMework design
Page
15
3 Figure 1-1. New Project Template Choose options for the new project (Figure 1-2): Product Name: Your new product’s name This will be the name of the framework project. A folder with the same name will be created in the root directory of the project. Use SettingsFW for this project. Team: Your development team This field is a drop-down containing code signing identities associated with your Apple ID. You’ll need to select one to ensure the app comes from your organization when releasing it on the Apple App Store. If you need to create a code signing identity, you can do so after the framework has been created, using the corresponding Apple documentation.2 Organization Identifier: Your organization’s bundle identifier prefix This value will be prepended to the Bundle Identifier. 2 Synchronizing your code signing identities with Apple Developer Portal: https://developer. apple.com/documentation/xcode/sharing-your-teams-signing-certificates Chapter 1 Building the Foundations oF Modular FraMework design
Page
16
4 Language: Your primary implementation language This value should be set to Swift, as this book provides code samples in Swift. Testing System: XCTest or Swift Testing This value should be set to Swift Testing, as this book provides code samples using the Swift Testing framework. The remaining settings are arbitrary. Figure 1-2. New Project Settings Chapter 1 Building the Foundations oF Modular FraMework design
Page
17
5 Configuring an iOS Framework The Framework template sets most of the necessary project settings. If you still need to associate a Team with your framework, create one using the Apple documentation referenced in the previous step, download it, and select it (Figure 1-3): 1. Select the Xcode/Settings menu item 2. Select the Apple Accounts tab. If you aren’t logged into your Apple account, do so now, as this will automatically download your teams to the Team section 3. Close Settings and select the root node of the project in the Project Navigator 4. Select the default target under the Show project and target lists 5. Select the Signing & Capabilities tab 6. Select Automatically manage signing under the Signing section 7. Select your team in the Team drop-down list Figure 1-3. Signing & Capabilities Settings Chapter 1 Building the Foundations oF Modular FraMework design
Page
18
6 Once the project has been created, the DEFINES_MODULE setting under the Build Settings/Packaging section can be set to YES to package the framework as a Swift module, allowing it to be imported with “import [framework name]” in Swift code, as well as exposing any public Objective-C headers through an umbrella header. If an umbrella header is needed to expose Objective-C headers, the following steps will need to be performed: 1. Right-click the framework folder within the Project Navigator and select New File from Template… 2. Choose the Header File template under the Source section and Next 3. Input a name for the file, e.g., SettingsFW.h, and create the file 4. Select the Root node within the Project Navigator 5. Select the Build Phases tab, expand the Headers section, and drag the umbrella file to the Public list (Figure 1-4) 6. Select the umbrella file within the Project Navigator and insert the following (using the appropriate framework name): #import <Foundation/Foundation.h> //! Project version number for SettingsFW. FOUNDATION_EXPORT double SettingsFWVersionNumber; //! Project version string for SettingsFW. FOUNDATION_EXPORT const unsigned char SettingsFWVersionString[]; // MARK: - Public Objective-C Headers // Import all headers you want visible to Swift here // MARK: - Optional Swift Interop // Swift-only classes are automatically available, no imports needed Fun Fact: Previous versions of Xcode used to generate this file automatically. Chapter 1 Building the Foundations oF Modular FraMework design
Page
19
7 Figure 1-4. Build Phase Settings Creating a Storyboard iOS Frameworks can provide different types of functionality you may want to use in a mobile app, including Swift class extensions, common utilities, Third-Party API integrations, and feature sets. In this example, a User Interface Storyboard feature will be developed using Interface Builder. Later in the book, a more involved SwiftUI User Interface will be created. 1. Right-click on the framework folder within the Project Navigator and select New File from Template… 2. Select the Storyboard template under the User Interface group (Figure 1-5) and Next 3. Save the file as SettingsUI.storyboard Chapter 1 Building the Foundations oF Modular FraMework design
Page
20
8 Figure 1-5. New File Template Window Creating a User Interface This framework will represent account settings. You can practice developing this UI using Interface Builder, or you can download the source code from GitHub and replace the Storyboard file contents as follows: 1. Right-click SettingsUI.storyboard in the Project Navigator and select Open As/Source Code 2. Select the file contents and delete it 3. Open the downloaded SettingsUI.storyboard file in a text editor and paste it into the project’s .storyboard file 4. Right-click the storyboard file in the Project Navigator and select Open As/Interface Builder - Storyboard (Figure 1-6) Chapter 1 Building the Foundations oF Modular FraMework design