DeallocTests 4.0: dependency injection as a package trait, deprecate DeallocTester - #21
Open
DanielCech wants to merge 9 commits into
Open
DanielCech wants to merge 9 commits into
DanielCech wants to merge 9 commits into
Conversation
- One DeallocTests target; STRV Dependency Injection behind the DependencyInjection trait (off by default, not downloaded when off) - Remove the DeallocTestsDIFree product and the symlinked target - Require Swift 6.1 (tools-version 6.1) - Deprecate DeallocTester, DeallocTest, DeallocTestable, ClassNameIdentifiable - Remove DefaultInitializable - DIFree sample uses expectDeallocation with XCTest; DI sample enables the trait - CI tests both trait configurations, samples build on macos-26 - README migration guide, CHANGELOG BREAKING CHANGE: DeallocTestsDIFree is removed and DI support requires the DependencyInjection trait. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Most projects use STRV Dependency Injection, so it's on by default. Projects that don't use it opt out with `traits: []` (or an empty traits list in an Xcode project) and the dependency isn't downloaded. - DI sample relies on the default trait - DIFree sample opts out in its Xcode project - CI tests the default and --disable-default-traits Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Swift names private and local types Module.(unknown context at $…).Name. Found while adopting DeallocTests in JustFlip. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The message named the protocol twice ("CreateDeckUseCase resolved for
CreateDeckUseCase") and didn't say why the check is skipped. Found while
adopting DeallocTests in JustFlip, whose deck use cases are structs.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Hints only inspect the leaked object's own properties. In JustFlip, a SettingsCoordinator kept alive by its parent's childCoordinators got a hint about its own cancellables; the message now also says the object may be held from outside (a parent's list of children, a cache, a singleton). Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@observable stores each property as _name and adds _$observationRegistrar. In JustFlip an @observable store's hint read `_cancellables`. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
In JustFlip's full test run, a host window sometimes took longer than 2 s to appear on a loaded simulator, failing the check with 'The test window could not be shown'. The waits return as soon as the state is reached. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
DeallocTests only uses AsyncContainer's init, clean(), releaseSharedInstances() and resolve(type:). JustFlip, on DI 1.x, needed a revision override to adopt DeallocTests 4; verified with a consumer pinned to DI 1.0.4. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Since the beginning, DeallocTests has come in two flavours:
DeallocTests(with STRV Dependency Injection) andDeallocTestsDIFree. They were built from one symlinked source folder with conditional compilation. That has three costs:Swift 6.1 added package traits, the official way to make part of a package optional. And since #19, there's a simpler API (
expectDeallocation) that makes the originalDeallocTesterunnecessary.What changes for users
One product; dependency injection is on by default, with an opt-out
There's now a single
DeallocTestsproduct. STRV Dependency Injection support is theDependencyInjectiontrait, which is on by default, because most of our projects use it. Projects that don't can turn it off:What I verified:
ios-dependency-injection, andtraits: []creates no pin at all.traits = ( );on its package reference, and Xcode doesn't check it out at all. There's a known report of Xcode ignoring disabled default traits in some workspace setups, but it doesn't affect a regular project with a package reference.DeallocTesteris deprecatedDeallocTester,DeallocTestandDeallocTestablestill work, but they show deprecation warnings pointing toexpectDeallocation. They'll be removed in 5.0. The README has a before/after example and a table mapping every old feature to its replacement (checkClasses→trackForDeallocation,actionBeforeCheck→afterRelease, and so on).Removed
DeallocTestsDIFreeproduct. UseDeallocTestsandimport DeallocTests.DefaultInitializable(deprecated in 3.1, unrelated to dealloc testing).New minimums
Sample apps
DeallocTestsAppDIFreeSPMis now the XCTest example ofexpectDeallocation. It has no conformances file, and each screen is a one-line test. The deliberate leak is reported on the test's line with thesomeClosurehint.DeallocTestsAppDIFreeSPMalso shows the opt-out: its Xcode project turns the trait off.DeallocTestsAppSPMuses the default trait and is the Swift Testing example. ItsDeallocTestertests stay as a reference for the deprecated API.Tests and CI
swift testpasses in the default configuration and with--disable-default-traits(25 and 22 Swift Testing tests plus the XCTest suites). The library builds with zero warnings in both.macos-26runner, because traits in an Xcode project need Xcode 26.4.Upgrading STRV projects
DeallocTestswith STRV Dependency Injection: bump to 4.0. Nothing else is required, butDeallocTestertests now show deprecation warnings.DeallocTestsDIFree: switch to theDeallocTestsproduct andimport DeallocTests, and turn off the default trait.🤖 Generated with Claude Code