From 761e42bf0b9f800b286551c0d33750f8fb6e9963 Mon Sep 17 00:00:00 2001 From: Dan Date: Sat, 4 Apr 2026 00:02:57 -0700 Subject: [PATCH 1/2] Pre-release polish for 2.0.0 - Update Manual macro count from four to five, add @SafeDIConfiguration to table - Migration plugin now generates all four @SafeDIConfiguration properties - Add CocoaPods deprecation note to migration guide - Replace default: with exhaustive cases in TypeDescription.strippingEscaping Co-Authored-By: Claude Opus 4.6 (1M context) --- Documentation/Manual.md | 3 ++- .../MigrateSafeDIFromVersionOne.swift | 7 +++++++ README.md | 5 +++-- Sources/SafeDICore/Models/TypeDescription.swift | 15 ++++++++++++++- 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/Documentation/Manual.md b/Documentation/Manual.md index 2a1d239f..0ce32bbb 100644 --- a/Documentation/Manual.md +++ b/Documentation/Manual.md @@ -4,7 +4,7 @@ This manual provides a detailed guide to using SafeDI effectively in your Swift ## Macros -There are a total of four macros in the SafeDI library: +There are a total of five macros in the SafeDI library: | Macro | Decorating | Usage | | ------ | ---------- | ----- | @@ -12,6 +12,7 @@ There are a total of four macros in the SafeDI library: | [`@Instantiated`](#instantiated) | Property declaration | Instantiates an instance or value when the enclosing `@Instantiable`-decorated type is instantiated. | | [`@Forwarded`](#forwarded) | Property declaration | Propagates a runtime-created instance or value (e.g. a `User` object, network response, or customer input) down the dependency tree. | | [`@Received`](#received) | Property declaration | Receives an instance or value from an `@Instantiated` or `@Forwarded` property further up the dependency tree. | +| [`@SafeDIConfiguration`](#configuration) | Enum declaration | Provides build-time configuration for SafeDI's code generation plugin. | Let’s walk through each of these macros in detail. diff --git a/Plugins/MigrateSafeDIFromVersionOne/MigrateSafeDIFromVersionOne.swift b/Plugins/MigrateSafeDIFromVersionOne/MigrateSafeDIFromVersionOne.swift index 5381a3d3..b21023ee 100644 --- a/Plugins/MigrateSafeDIFromVersionOne/MigrateSafeDIFromVersionOne.swift +++ b/Plugins/MigrateSafeDIFromVersionOne/MigrateSafeDIFromVersionOne.swift @@ -159,6 +159,13 @@ struct MigrateSafeDIFromVersionOne: CommandPlugin { \t/// Directories containing Swift files to include, relative to the executing directory. \t/// This property only applies to SafeDI repos that utilize the SPM plugin via an Xcode project. \tstatic let additionalDirectoriesToInclude: [StaticString] = \(directoriesToIncludeArray) + + \t/// Whether to generate `mock()` methods for `@Instantiable` types. + \tstatic let generateMocks: Bool = true + + \t/// The conditional compilation flag to wrap generated mock code in. + \t/// Set to `nil` to generate mocks without conditional compilation. + \tstatic let mockConditionalCompilation: StaticString? = "DEBUG" } """ } diff --git a/README.md b/README.md index 3cb04d86..8c9d1892 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,6 @@ dependencies: [ ] ``` -> **Note:** SafeDI 2.x requires Swift 6.3 or later. Projects using an earlier Swift version should use SafeDI 1.x. To install the SafeDI framework into an Xcode project with Swift Package Manager, follow [Apple’s instructions](https://developer.apple.com/documentation/xcode/adding-package-dependencies-to-your-app) to add `https://github.com/dfed/SafeDI.git` as a dependency. @@ -168,7 +167,9 @@ Other Swift DI libraries, like [Factory](https://github.com/hmlongco/Factory) an ## Migrating from SafeDI 1.x to 2.x -SafeDI 2.x requires Swift 6.3 or later and removes support for CSV-based configuration files (`.safedi/configuration/include.csv` and `.safedi/configuration/additionalImportedModules.csv`). Configuration is now done via the `@SafeDIConfiguration` macro. +SafeDI 2.x requires Swift 6.3 or later and does not support CocoaPods. Projects using an earlier Swift version or CocoaPods should use SafeDI 1.x. + +SafeDI 2.x also removes support for CSV-based configuration files (`.safedi/configuration/include.csv` and `.safedi/configuration/additionalImportedModules.csv`). Configuration is now done via the `@SafeDIConfiguration` macro. ### Automated migration diff --git a/Sources/SafeDICore/Models/TypeDescription.swift b/Sources/SafeDICore/Models/TypeDescription.swift index 25f75c28..b93d9206 100644 --- a/Sources/SafeDICore/Models/TypeDescription.swift +++ b/Sources/SafeDICore/Models/TypeDescription.swift @@ -388,7 +388,20 @@ public enum TypeDescription: Codable, Hashable, Comparable, Sendable { } else { return type } - default: + case .any, + .array, + .closure, + .composition, + .dictionary, + .implicitlyUnwrappedOptional, + .metatype, + .nested, + .optional, + .simple, + .some, + .tuple, + .unknown, + .void: return self } } From 789139266a757903418b31acd638aa3ee413a815 Mon Sep 17 00:00:00 2001 From: Dan Federman Date: Sat, 4 Apr 2026 00:05:05 -0700 Subject: [PATCH 2/2] Apply suggestion from @dfed --- Documentation/Manual.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/Manual.md b/Documentation/Manual.md index 0ce32bbb..f533bf1a 100644 --- a/Documentation/Manual.md +++ b/Documentation/Manual.md @@ -12,7 +12,7 @@ There are a total of five macros in the SafeDI library: | [`@Instantiated`](#instantiated) | Property declaration | Instantiates an instance or value when the enclosing `@Instantiable`-decorated type is instantiated. | | [`@Forwarded`](#forwarded) | Property declaration | Propagates a runtime-created instance or value (e.g. a `User` object, network response, or customer input) down the dependency tree. | | [`@Received`](#received) | Property declaration | Receives an instance or value from an `@Instantiated` or `@Forwarded` property further up the dependency tree. | -| [`@SafeDIConfiguration`](#configuration) | Enum declaration | Provides build-time configuration for SafeDI's code generation plugin. | +| [`@SafeDIConfiguration`](#configuration) | Enum declaration | Provides build-time configuration for SafeDI’s code generation plugin. | Let’s walk through each of these macros in detail.