Create, Push, and Present Any View Controller in 1 LOC using Metaprogramming

This page summarizes the projects mentioned and recommended in the original post on dev.to

Our great sponsors
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • SaaSHub - Software Alternatives and Reviews
  • uiviewcontroller-metaprogramming

    A supplementary example for an article https://bit.ly/3qNnRcu

  • We make view controller instantiation more type-safe by eliminating string IDs and use metaprogramming to generate functions that let you create, push, and present any view controller in 1 LOC, so you can save ~15 LOC whenever you want to perform push or present. It works both with storyboard-based view controllers and code-only ones. The generated code is autocomplete-friendly. Here is the full source code example.

  • Insanity

    Meta-programming for Swift, stop writing boilerplate code.

  • Now that we have designed our APIs we can generate the code. For each view controller in our project, we are going to generate 3 functions: create, push, and present. We are going to generate code with Sourcery — a tool developed by Krzysztof Zabłocki.

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
  • SwiftGen

    The Swift code generator for your assets, storyboards, Localizable.strings, … — Get rid of all String-based APIs!

  • It is important to say that there is an elegant solution to the resource consistency problem that we haven’t adapted yet. Instead of testing raw values of UIStoryboard.Name cases, we could just generate the UIStoryboard.Name enum. Please refer to SwiftGen for the details.

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts