Repository navigation
·
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,
generatedoes 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
Instantiatorof 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. generateskips its work when nothing it reads has changed since its last run. A build that changes no Swift file of a module, and no settinggeneratereads, 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 fromsafeDIOverridesby 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
LazilyInstantiatedvalue sits on a cycle ofInstantiators, 2.4.5’s mock created it when the cycle’s builder was called; the mock now creates it the first timeinstanceis 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
mockAttributesspell. Where a module’s mock configuration takes itsSendableform, 2.4.5 made a type’s override closure@Sendableand dropped the@MainActorthat the type’smockAttributesspell, so a preview that passed a closure calling a@MainActorinitializer 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