iOS Inside #002 – Don’t ship a monster Modularization, architecture & SwiftUI tricks to keep your code sane

iOS InsideiOS Inside
3 min read

Hey dev,
Let’s be honest: shipping features is cool, but maintaining a tangled codebase 6 months later? Not so much.

This drop is about keeping your project clean, modular, and future-you-friendly — especially if you’re working with SwiftUI or trying to scale up your architecture.

Let’s break it down:


1. Don’t wait to modularize

You don’t need a team of 10 to modularize your app.
You don’t even need more than one dev.

Modularization is about separation of concerns — keeping features, services, UI components and core logic in separate packages or targets.

Even in smaller projects, this helps with:

  • Build time (faster previews in SwiftUI)

  • Reusability (across apps or targets)

  • Clean separation between layers

  • Testing without pulling the entire app up


2. Clean doesn’t mean overkill

Forget the "Clean Architecture" buzzwords for a second.
The key is consistency + clarity.

Here's a setup that works in most real-world apps:

/App
  /Home
    - HomeView.swift
    - HomeViewModel.swift
    - HomeRouter.swift
  /Shared
    - ButtonStyles.swift
    - Extensions.swift
  /Core
    - NetworkService.swift
    - Models.swift

You can convert these folders into Swift Packages later, but even just organizing like this gives your brain a break.


3. SwiftUI tricks that save your sanity

We all love SwiftUI... until the layout breaks for no reason.
Here are 3 things that help:

a) ViewBuilders > giant body blocks

Split big UIs into small ViewBuilder funcs:

var body: some View {
    VStack {
        header
        list
        footer
    }
}

private var header: some View {
    Text("Welcome")
        .font(.largeTitle)
}

b) Use @ViewBuilder for reusability

@ViewBuilder
func EmptyStateView(title: String, icon: String) -> some View {
    VStack(spacing: 12) {
        Image(systemName: icon)
        Text(title)
    }
    .padding()
}

c) Preview everything

Preview files in isolation. Even stuff like ButtonStyles.swift.
It saves time and makes refactors way safer.


4. Bonus: app structure mindset

Don’t build everything in ContentView.swift.
Start with an AppCoordinator (even a simple enum-based one) and make your navigation explicit. It’s gonna save you a lot of pain later.


5. Quick Xcode command tip

Want to clean your project without digging through menus?

⇧ + ⌘ + K // Clean build folder

Need a full reset? Delete DerivedData manually:

rm -rf ~/Library/Developer/Xcode/DerivedData

Optional: create a terminal alias to make your life easier:

alias xcclean='rm -rf ~/Library/Developer/Xcode/DerivedData'

Then just run xcclean whenever you wanna nuke Xcode’s mess.

Bonus:

xcodebuild -showsdks

...to list installed SDKs and available platforms.


6. Wrap-up

Clean code isn’t about perfection — it’s about survival.
Modularization helps. Structure matters. And SwiftUI’s not magic, but it becomes fun with the right habits.

Next drop?
We’re diving into Swiftly 1.0 (yes, the CLI that’s winning hearts), async testing, and more dev-life hacks.

Until then:
Build. Run. Refactor. And don’t ship a monster.

0
Subscribe to my newsletter

Read articles from iOS Inside directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

iOS Inside
iOS Inside