Skip to content

2.4.6

Latest

Choose a tag to compare

@dfed dfed released this 03 Dec 20:28
· 12 commits to main since this release
Immutable release. Only release title and notes can be modified.

Performance

  • Generated mocks compile much faster. A generated app of a million lines builds clean in debug in 400 to 432 seconds on 4 cores, against 1,030 to 1,071 seconds with 2.4.5. Its generated mocks are 305,488 lines, where 2.4.5 wrote 1,162,809.
  • Modules that generate mocks do less work and write less code. In a generated app of twelve modules whose screens each have a mock, generate does 22% less work than 2.4.5 and writes 46% fewer lines. In a module of 150 mocks it does 32% less work.
  • A type that holds an Instantiator of its own type is planned once. A chain of 100 such screens takes a seventh of 2.4.5’s work and 40% less memory.
  • generate skips its work when nothing it reads has changed since its last run. A build that changes no Swift file of a module, and no setting generate reads, no longer regenerates the module’s code. (#1195)

Generated mocks

Generated mocks are now planned once per type instead of once per path through the module. The values a mock builds, the overrides it honors, mock()’s parameters, and the fields of SafeDIOverrides and SafeDIMockConfiguration are unchanged; only the isolation of an override’s closure changes, as Fixes describes. The bodies of generated mocks are laid out differently:

  • A mock’s builder functions sit side by side. Each builder is a sibling of the functions that call it and takes its SafeDIMockConfiguration (or override closure) as an argument. 2.4.5 nested each builder inside its caller, where it read its configuration from safeDIOverrides by path.
  • Properties of one type whose builders are alike share one function, named for the first of them. 2.4.5 wrote a function per property.
  • A builder that several mocks of a module need is written once and called from each. Its name starts with __safeDI_, so only generated code calls it.

Generated production code

Production code builds the same values as 2.4.5’s, in the same order, and every initializer’s signature is unchanged. In some shapes, a generated initializer declares its local builder functions in other places, under other names, or shared between properties.

Fixes

  • A build no longer fails when the project is reached through a symbolic link. Under the SafeDIGenerator plugin, such a build failed with “Found @INSTANTIABLE(isRoot: true) in ‘…’, but this file is not listed in the manifest” whenever SafeDI had to read the module’s files afresh. (#1184)
  • A mock no longer makes a lazily instantiated value before something reads it. Where a LazilyInstantiated value sits on a cycle of Instantiators, 2.4.5’s mock created it when the cycle’s builder was called; the mock now creates it the first time instance is read, as production does. A test that counted on the earlier creation sees it later; every other pair of values is created in the same order.
  • A mock’s overrides keep the main actor its type’s mockAttributes spell. Where a module’s mock configuration takes its Sendable form, 2.4.5 made a type’s override closure @Sendable and dropped the @MainActor that the type’s mockAttributes spell, so a preview that passed a closure calling a @MainActor initializer or mock did not compile. 2.4.6 types the closure with those attributes, such as @Sendable @MainActor (Shelf) -> Loader. (#1222)

Full Changelog: 2.4.5...2.4.6