Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Enhancing Swift Development through Modularizat...

Enhancing Swift Development through Modularization and Automation

This presentation delves into the concept of Swift modularization, highlighting the practice of breaking down monolithic codebases into smaller, more manageable subprojects. We will discuss the various automation tools available that can streamline the creation and management of these subprojects, making the development process more efficient. Additionally, we will explore the benefits of a modularized codebase, such as improved parallel build processes, faster build times, easier maintenance, and enhanced scalability. Attendees will gain practical insights and strategies to optimize their Swift development workflow for increased efficiency and productivity.

https://youtu.be/E5J_9M3EQVY?si=4W-jIAlclZTttay8

Mani Ramezan

May 29, 2024
Tweet

More Decks by Mani Ramezan

Other Decks in Programming

Transcript

  1. About me • M a ni (M a a ni)

    R a mez a n • St aff Engineer a t LinkedIn • Kodeco • Tech editor • Discord iOS moder a tor • Previous bootc a mp mentor
  2. Agenda • Modul a riz a tion in Swift •

    Autom a tion tooling • Gener a l tips a nd tricks • Q&A
  3. Modularization in Swift What’s a module in Swift “A module

    is a single unit of code distribution — a framework or application that’s built and shipped as a single unit and that can be imported by another module with Swift’s import keyword.” Swift Docs
  4. Modularization in Swift Bene fi ts of modularization • Provides

    n a mesp a cing • Encour a ge implementing code th a t’s: • Reus a ble • Sc a l a ble • M a int a in a ble
  5. Modularization in Swift Faster build • Better resource utiliz a

    tion • Build multiple modules simult a neously • Single module • Module c a ching • E a sier to scope the e ff ect of ch a nges • Help compiler to help you App M1 M2 App M3 M4
  6. Modularization in Swift Look out for • Mixing Objc a

    nd Swift code together • C a n result in overly complic a ted dependency gr a ph • Alw a ys pro f ile the build • Be c a utious a bout a dding new dependencies between modules
  7. Automation tooling Why automate? • Cre a te a Xcode

    project • Add the project to worksp a ce • Build settings • Bundle identi f ier • Codesigning • Min deployment • Compiler f l a gs
  8. Automation tooling Tooling • coco a pods/xcodeproj • Written in

    ruby • Used by coco a pods • H a s gre a t document a tion • tuist/xcodeproj • Written in Swift • Used by B a zel
  9. Automation tooling Xcode project structure • xcworksp a ce •

    xcodeproj • T a rget • xccon f ig • Source f ile • Resources • …
  10. Automation tooling xcworkspace MyWorkspace.xcworkspace ├ xcshareddata │├ IDEWorkspaceChecks.plist -> General

    workplace checks and settings ├ xcuserdata -> Used by Xcode to store user states ├ contents.xcworkspacedata -> Includes references to xcodeproj fi les
  11. Automation tooling xcodeproj MyAwesomeApp.xcodeproj ├ xcshareddata │├ xcschemes ├ xcuserdata

    -> User speci fi c con fi gs used by Xcode ├ project.pbxproj • Where most of your automation work is done • No o ff i cial documentation • Each item is assigned a unique identi fi er • ASCII/NeXTSTEP Property List
  12. Automation tooling Build con fi guration • C a n

    sh a re Build Settings by using con f igur a tion f iles • Multiple con f igur a tions c a n be combined together • #include “Sh a red.xccon f igs
  13. Automation tooling Tip on reading each con fi g docs

    • a lt+double click a ny item in Build Setting to bring up the document a tion a nd the environment v a ri a ble n a me for th a t setting
  14. Automation tooling Automated steps • Cre a te a new

    xcodeproj • Add m a in t a rget a nd unit test t a rgets • Add con f igur a tion • Add def a ult f iles like unit test a nd umbrell a he a der • Upd a te your m a in pbxproj f ile to a dd this new fr a mework a s a dependency
  15. General tips and tricks • Alw a ys cre a

    te a b a se xccon f ig f ile • T a ke a dv a nt a ge of con f igur a tion hier a rchy • If possible, move to y a ml structure a nd use XcodeGen or tools like B a zel to gener a te projects • No more merge con f lict on pbxproj • Modul a rized unit a nd UI tests a s well • Cre a te unit a nd UI test util fr a meworks