Add feature module target to your iOS app

Aleksa Simic
June 27, 2024
10 min read

Motivation

For some time, I am working on researching how large scale iOS apps work, and at the same time, implement all of the findings on a one pretty large scale iOS project I am working on at the moment.

Every big iOS application, heavily relies on modularization and creating feature modules for better separation of concerns, reducing build times, fast previews, and improving development speed and experience.

Bunch of these large organizations also take it a step further by creating a separate runnable targets for each feature module in their iOS apps. This approach allows feature teams to not have to build to whole app in order to contribute to the codebase and add new things or fix bugs in the feature module they are responsible for.

During my modularization research, I noticed that a lot of people want to get started with modularization in their iOS apps but don't know where to start when they want to create a runnable target for a feature module. I was in a similar situation myself once. That's the reason why I decided to make a step by step guide on how to do it the right way.

If you are looking to learn about modularization of iOS apps, I highly recommend you to start with this video: Bruno Rocha: Preparing for Growth: Architecting Giant Apps for Scalability and Build Speed

Step by step guide for adding a feature module target to an iOS project

These are the list of steps needed to create a feature module target: 

1. Creating a feature module as a SPM package

Add feature module as a SPM package

2. Choosing a feature module package name

Choose feature module name

3. Overview of the project after feature module creation

This is how your project will look like after feature module creation

4. Add a feature module target

Adding a feature module target

5. Choose App in the target template picker

Choosing app in the target template picker

6. Overview of the project after feature module target creation

Overview of the project after target creation

7. Link the previously created feature module SPM package to a feature target

Link the feature module package to your newly created target

8. Run the app and enjoy your modularized iOS application!

Conclusion

Modularizing your iOS apps doesn't have to be that difficult. While I strongly recommend you to go through this step by step process of feature module package and feature module target creation, I have also created a GitHub repository where you can find the the example project. You can find it here.

Aleksa Simic
Co-Founder & CEO of Aetherius Solutions
Share this post
Trending

The most popular e-books and project templates

iOS engineers from all over the world found these e-books and project templates as the ultimate source of knowledge needed to build and scale their mobile apps

Blog

Latest blogs

Kotlin Multiplatform
Kotlin Multiplatform vs Compose Multiplatform in building production ready mobile applications
iOS
Is MV pattern in SwiftUI ready to replace MVVM?
iOS
Step by step guide for creating feature module targets in iOS apps