MihaelIsaev / MihaelIsaev/UIKitPlus

Avoid launching main app if rendering previews

Open
#25 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Swift
Stars
628
Forks
36
PR merge metrics
No merged PRs in 30d

Description

Rendering preview's can be optimised by checking XCODE_RUNNING_FOR_PREVIEWS environment variable

@AppBuilder override var body: AppBuilderContent {
  MainScene { .main }
  .mainScreen {
    // Avoid loading `ShowsListViewController` is rendering previews:
    if ProcessInfo.processInfo.environment["XCODE_RUNNING_FOR_PREVIEWS"] == "1" {
      return UIViewController()
    }
    return NavigationController(ShowsListViewController(viewModel: ShowsListViewModel()))
      .style(.transparent)
      .hideNavigationBar()
  }
}

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the app entry point containing the MainScene and .mainScreen declaration, and inspect how ShowsListViewController is created. Use XCODE_RUNNING_FOR_PREVIEWS as the preview condition, then verify that previews avoid loading the main screen while the normal app path still creates the navigation controller.

Written by the indexing model from the issue text.

Assessment

Tech stack
swift
Domain
mobile
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.