GitXplorerGitXplorer
T

swiftUI-env-lifecycle

public
1 stars
0 forks
0 issues

Commits

List of commits on branch main.
Unverified
a73ffd381661c6c166407df7402f1d0fc43a7527

Add blog post link to README

TTiagoMaiaL committed 2 years ago
Unverified
7a302aa19a9c52dbf953cc8c95fb17a1abb045da

Ignore .DS_Store files

TTiagoMaiaL committed 2 years ago
Unverified
f8f35d3bc26a06c526ae1c88d5d6e8e946fadbb2

Improve README.md

TTiagoMaiaL committed 2 years ago
Unverified
a50f8ccf26d0689f76eff7de152fdbb43d9f4191

Add link to memory graph explanation

TTiagoMaiaL committed 2 years ago
Unverified
8f2fe33bd5fec198bbe8ca9487f6908a517f0a86

Add instructions on how to return to HEAD

TTiagoMaiaL committed 2 years ago
Unverified
95ef00a7ecaf1a505d4861832160c9d6f9ec8d5e

Add screenshot

TTiagoMaiaL committed 2 years ago

README

The README file for this repository.

swiftUI-env-lifecycle

A project containing some scenarios on when the SwiftUI environment gets retained, for apps integrating UIKit with SwiftUI and vice-versa.

The scenarios:

  1. Holding a View instance
  2. Holding a reference to a UIHostingController instance
  3. Having a UIView with a retain cycle
  4. Having a retain cycle between a UIView and an environment object

Exploring the scenarios

Each scenario has a git tag pointing to it. To explore the scenarios, do the following:

  1. Begin by checking it out: e.g git checkout scenario-1
  2. Run the app in the simulator
  3. Tap the "Remove RootView from UI" button (when applicable)
  4. Build the memory graph and look for the environment instances (EnvA and EnvB)
  5. Fix the scenario, properly releasing the environment, making sure it doesn't appear in the memory graph
  6. When you are done, you can return to git's HEAD: git switch -

Make sure to check this blog post as well. It'll guide your experience.

The project UI

Some scenarios might require you to remove the SwiftUI views from the screen. You can do this by tapping at the "Remove RootView from UI" button: