From 6cb178c0eed136a8d9769d6e71dd23c5e172dd3f Mon Sep 17 00:00:00 2001 From: Dan Federman Date: Thu, 15 Jan 2026 16:13:52 -0800 Subject: [PATCH 1/7] Failing test --- .../InstantiableMacroTests.swift | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/Tests/SafeDIMacrosTests/InstantiableMacroTests.swift b/Tests/SafeDIMacrosTests/InstantiableMacroTests.swift index e96cc1a7..19671f87 100644 --- a/Tests/SafeDIMacrosTests/InstantiableMacroTests.swift +++ b/Tests/SafeDIMacrosTests/InstantiableMacroTests.swift @@ -1935,6 +1935,76 @@ import SafeDICore } } + @Test + func declaration_fixit_updatesRequiredInitializerWhenAllDependenciesMissingFromInit() { + assertMacro { + """ + @Instantiable + public struct ExampleService: Instantiable { + public init() { + } + + @Received let received: Received + @Instantiated let instantiated: Instantiated + @Forwarded let forwarded: Forwarded + } + """ + } diagnostics: { + """ + @Instantiable + public struct ExampleService: Instantiable { + public init() { + ╰─ 🛑 @Instantiable-decorated type must have a `public` or `open` initializer with a parameter for each @Instantiated, @Received, or @Forwarded-decorated property. + ✏️ Add arguments for received: Received, instantiated: Instantiated, forwarded: Forwarded + } + + @Received let received: Received + @Instantiated let instantiated: Instantiated + @Forwarded let forwarded: Forwarded + } + """ + } fixes: { + """ + @Instantiable + public struct ExampleService: Instantiable { + public init( + received: Received, + instantiated: Instantiated, + forwarded: Forwarded + ) { + self.received = received + self.instantiated = instantiated + self.forwarded = forwarded + } + + @Received let received: Received + @Instantiated let instantiated: Instantiated + @Forwarded let forwarded: Forwarded + } + """ + } expansion: { + """ + public struct ExampleService: Instantiable { + public init( + received: Received, + instantiated: Instantiated, + forwarded: Forwarded + ) { + self.received = received + self.instantiated = instantiated + self.forwarded = forwarded + } + + let received: Received + let instantiated: Instantiated + let forwarded: Forwarded + + public typealias ForwardedProperties = Forwarded + } + """ + } + } + @Test func declaration_fixit_updatesRequiredInitializerWhenIncorrectAccessibilityOnInitAndOtherNonConformingInitializersExist() { assertMacro { From 3cbd51ee6da6deb9435bed09d871853fbdad9aca Mon Sep 17 00:00:00 2001 From: Dan Federman Date: Thu, 15 Jan 2026 16:29:51 -0800 Subject: [PATCH 2/7] Improved --- .../Macros/InstantiableMacro.swift | 4 ++- .../InstantiableMacroTests.swift | 28 +++++++++---------- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/Sources/SafeDIMacros/Macros/InstantiableMacro.swift b/Sources/SafeDIMacros/Macros/InstantiableMacro.swift index 9c5b3f6f..b5cd0fcf 100644 --- a/Sources/SafeDIMacros/Macros/InstantiableMacro.swift +++ b/Sources/SafeDIMacros/Macros/InstantiableMacro.swift @@ -274,7 +274,9 @@ public struct InstantiableMacro: MemberMacro { return existingAssignment } else { var propertyAssignment = $0.asPropertyAssignment() - propertyAssignment.leadingTrivia = body.statements.first?.leadingTrivia ?? [] + if let leadingTrivia = body.statements.first?.leadingTrivia { + propertyAssignment.leadingTrivia = leadingTrivia + } return propertyAssignment } } diff --git a/Tests/SafeDIMacrosTests/InstantiableMacroTests.swift b/Tests/SafeDIMacrosTests/InstantiableMacroTests.swift index 19671f87..11512792 100644 --- a/Tests/SafeDIMacrosTests/InstantiableMacroTests.swift +++ b/Tests/SafeDIMacrosTests/InstantiableMacroTests.swift @@ -1968,13 +1968,13 @@ import SafeDICore @Instantiable public struct ExampleService: Instantiable { public init( - received: Received, - instantiated: Instantiated, - forwarded: Forwarded - ) { - self.received = received - self.instantiated = instantiated - self.forwarded = forwarded + received: Received, + instantiated: Instantiated, + forwarded: Forwarded + ) { + self.received = received + self.instantiated = instantiated + self.forwarded = forwarded } @Received let received: Received @@ -1986,13 +1986,13 @@ import SafeDICore """ public struct ExampleService: Instantiable { public init( - received: Received, - instantiated: Instantiated, - forwarded: Forwarded - ) { - self.received = received - self.instantiated = instantiated - self.forwarded = forwarded + received: Received, + instantiated: Instantiated, + forwarded: Forwarded + ) { + self.received = received + self.instantiated = instantiated + self.forwarded = forwarded } let received: Received From 4d1fa521ea369e88f8ccb7c6f979f6a4f63ae3b9 Mon Sep 17 00:00:00 2001 From: Dan Federman Date: Thu, 15 Jan 2026 18:06:36 -0800 Subject: [PATCH 3/7] Update iOS CI version to 18.5 --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index daf46df4..7fda45f3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -117,7 +117,7 @@ jobs: - name: Install Pod run: bundle exec pod install --project-directory=Examples/ExampleCocoaPodsIntegration - name: Build CocoaPods Integration - run: xcrun xcodebuild build -scheme ExampleCocoaPodsIntegration -configuration Debug -workspace Examples/ExampleCocoaPodsIntegration/ExampleCocoaPodsIntegration.xcworkspace -destination 'platform=iOS Simulator,OS=18.4,name=iPad (10th generation)' # Explicitly test the Debug build. Our pod lint jobs are already testing the Release build. + run: xcrun xcodebuild build -scheme ExampleCocoaPodsIntegration -configuration Debug -workspace Examples/ExampleCocoaPodsIntegration/ExampleCocoaPodsIntegration.xcworkspace -destination 'platform=iOS Simulator,OS=18.5,name=iPad (10th generation)' # Explicitly test the Debug build. Our pod lint jobs are already testing the Release build. spm: name: Build and Test on Xcode 16 From cd4fa5b82d5f5c4f0f16ae2de8290fa3c4dc9f32 Mon Sep 17 00:00:00 2001 From: Dan Federman Date: Thu, 15 Jan 2026 18:45:18 -0800 Subject: [PATCH 4/7] download iOS before running iOS --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7fda45f3..d9a0dc97 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -116,6 +116,8 @@ jobs: run: sudo xcode-select --switch /Applications/Xcode_16.4.0.app/Contents/Developer - name: Install Pod run: bundle exec pod install --project-directory=Examples/ExampleCocoaPodsIntegration + - name: Download iOS + run: sudo xcodebuild -downloadPlatform iOS -buildVersion 22F77 -architectureVariant arm64 - name: Build CocoaPods Integration run: xcrun xcodebuild build -scheme ExampleCocoaPodsIntegration -configuration Debug -workspace Examples/ExampleCocoaPodsIntegration/ExampleCocoaPodsIntegration.xcworkspace -destination 'platform=iOS Simulator,OS=18.5,name=iPad (10th generation)' # Explicitly test the Debug build. Our pod lint jobs are already testing the Release build. From c07687036019c7a995c1cffb364ff81d3aaf044b Mon Sep 17 00:00:00 2001 From: Dan Federman Date: Thu, 15 Jan 2026 18:59:12 -0800 Subject: [PATCH 5/7] no architecture variant --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d9a0dc97..f49cc53f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -117,7 +117,7 @@ jobs: - name: Install Pod run: bundle exec pod install --project-directory=Examples/ExampleCocoaPodsIntegration - name: Download iOS - run: sudo xcodebuild -downloadPlatform iOS -buildVersion 22F77 -architectureVariant arm64 + run: sudo xcodebuild -downloadPlatform iOS -buildVersion 22F77 - name: Build CocoaPods Integration run: xcrun xcodebuild build -scheme ExampleCocoaPodsIntegration -configuration Debug -workspace Examples/ExampleCocoaPodsIntegration/ExampleCocoaPodsIntegration.xcworkspace -destination 'platform=iOS Simulator,OS=18.5,name=iPad (10th generation)' # Explicitly test the Debug build. Our pod lint jobs are already testing the Release build. From 6aa6220d70a388ef7d4b3f3d9e07035b8353f622 Mon Sep 17 00:00:00 2001 From: Dan Federman Date: Thu, 15 Jan 2026 22:58:43 -0800 Subject: [PATCH 6/7] improve ios download --- .github/workflows/ci.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f49cc53f..b4b1e081 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -117,7 +117,11 @@ jobs: - name: Install Pod run: bundle exec pod install --project-directory=Examples/ExampleCocoaPodsIntegration - name: Download iOS - run: sudo xcodebuild -downloadPlatform iOS -buildVersion 22F77 + run: | + sudo xcodebuild -runFirstLaunch + sudo xcrun simctl list + sudo xcodebuild -downloadPlatform iOS -buildVersion 22F77 + sudo xcodebuild -runFirstLaunch - name: Build CocoaPods Integration run: xcrun xcodebuild build -scheme ExampleCocoaPodsIntegration -configuration Debug -workspace Examples/ExampleCocoaPodsIntegration/ExampleCocoaPodsIntegration.xcworkspace -destination 'platform=iOS Simulator,OS=18.5,name=iPad (10th generation)' # Explicitly test the Debug build. Our pod lint jobs are already testing the Release build. From d5671058418a626659a0615336a28eb813cb451e Mon Sep 17 00:00:00 2001 From: Dan Federman Date: Thu, 15 Jan 2026 23:06:51 -0800 Subject: [PATCH 7/7] simplify --- .github/workflows/ci.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b4b1e081..82a2dbd3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,7 +36,6 @@ jobs: sudo xcodebuild -runFirstLaunch sudo xcrun simctl list sudo xcodebuild -downloadPlatform visionOS - sudo xcodebuild -runFirstLaunch - name: Build Framework run: xcrun xcodebuild -skipMacroValidation -skipPackagePluginValidation build -scheme SafeDI-Package -destination ${{ matrix.platforms }} @@ -121,7 +120,6 @@ jobs: sudo xcodebuild -runFirstLaunch sudo xcrun simctl list sudo xcodebuild -downloadPlatform iOS -buildVersion 22F77 - sudo xcodebuild -runFirstLaunch - name: Build CocoaPods Integration run: xcrun xcodebuild build -scheme ExampleCocoaPodsIntegration -configuration Debug -workspace Examples/ExampleCocoaPodsIntegration/ExampleCocoaPodsIntegration.xcworkspace -destination 'platform=iOS Simulator,OS=18.5,name=iPad (10th generation)' # Explicitly test the Debug build. Our pod lint jobs are already testing the Release build. @@ -180,7 +178,6 @@ jobs: sudo xcodebuild -runFirstLaunch sudo xcrun simctl list sudo xcodebuild -downloadPlatform ${{ matrix.platforms }} - sudo xcodebuild -runFirstLaunch - name: Lint Podspec run: bundle exec pod lib lint --verbose --fail-fast --swift-version=6.0 --platforms=${{ matrix.platforms }}