-
Notifications
You must be signed in to change notification settings - Fork 2
Added Publishable subclassing support #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
f296d6b
Removed redundant tests
NSFatalError 13fbbaa
Aligned computed property publishers behavior
NSFatalError ca967f2
-
NSFatalError 3aa89fa
[SwiftFormat] Applied formatting
NSFatalError 7a241aa
-
NSFatalError 346b74a
-
NSFatalError 79002db
[SwiftFormat] Applied formatting
NSFatalError c5b8de2
-
NSFatalError d149d39
-
NSFatalError ec4fbe9
[SwiftFormat] Applied formatting
NSFatalError 41aab39
-
NSFatalError 1313936
[SwiftFormat] Applied formatting
NSFatalError 0dbc61a
-
NSFatalError e88cfb2
-
NSFatalError bcfcd71
-
NSFatalError 852dcef
[SwiftFormat] Applied formatting
NSFatalError d188403
-
NSFatalError e001966
-
NSFatalError 2427908
-
NSFatalError db14844
[SwiftFormat] Applied formatting
NSFatalError f39be9e
-
NSFatalError 7beacb0
-
NSFatalError 8feca3b
[SwiftFormat] Applied formatting
NSFatalError 65baa00
-
NSFatalError 8ec3528
[SwiftFormat] Applied formatting
NSFatalError ef264b1
-
NSFatalError 15607ab
[SwiftFormat] Applied formatting
NSFatalError be9b359
-
NSFatalError b30f562
-
NSFatalError c4bddd0
-
NSFatalError 13b2a3f
[SwiftFormat] Applied formatting
NSFatalError b05b862
-
NSFatalError 95f7369
-
NSFatalError 57b437b
-
NSFatalError 8c98a25
-
NSFatalError a34a392
-
NSFatalError def73b1
Added docs
NSFatalError b19908c
-
NSFatalError 178c3af
-
NSFatalError 06a87f3
-
NSFatalError 0d5c052
[SwiftFormat] Applied formatting
NSFatalError 8af638f
-
NSFatalError 3f29a5a
-
NSFatalError 5b0e2ea
-
NSFatalError 4e65ed4
-
NSFatalError File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,7 @@ on: | |
| - '*' | ||
|
|
||
| env: | ||
| XCODE_VERSION: "26.1" | ||
| XCODE_VERSION: "26.0" | ||
|
|
||
| jobs: | ||
| release: | ||
|
|
||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| disabled_rules: | ||
| - function_body_length | ||
| - type_body_length | ||
| - no_magic_numbers |
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
Submodule PrincipleMacros
updated
56 files
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| // | ||
| // ObservableMacro.swift | ||
| // Relay | ||
| // | ||
| // Created by Kamil Strzelecki on 23/11/2025. | ||
| // Copyright © 2025 Kamil Strzelecki. All rights reserved. | ||
| // | ||
|
|
||
| import SwiftSyntaxMacros | ||
|
|
||
| internal enum ObservableMacro { | ||
|
|
||
| static let attribute: AttributeSyntax = "@Observable" | ||
| } |
25 changes: 25 additions & 0 deletions
25
Macros/RelayMacros/Combine/Common/ObservationIgnoredMacro.swift
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| // | ||
| // ObservationIgnoredMacro.swift | ||
| // Relay | ||
| // | ||
| // Created by Kamil Strzelecki on 22/11/2025. | ||
| // Copyright © 2025 Kamil Strzelecki. All rights reserved. | ||
| // | ||
|
|
||
| import SwiftSyntaxMacros | ||
|
|
||
| internal enum ObservationIgnoredMacro { | ||
|
|
||
| static let attribute: AttributeSyntax = "@ObservationIgnored" | ||
| } | ||
|
|
||
| extension Property { | ||
|
|
||
| var isStoredObservationTracked: Bool { | ||
| kind == .stored | ||
| && mutability == .mutable | ||
| && underlying.typeScopeSpecifier == nil | ||
| && underlying.overrideSpecifier == nil | ||
| && !underlying.attributes.contains(like: ObservationIgnoredMacro.attribute) | ||
| } | ||
| } |
187 changes: 187 additions & 0 deletions
187
Macros/RelayMacros/Combine/Common/PropertyPublisherDeclBuilder.swift
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,187 @@ | ||
| // | ||
| // PropertyPublisherDeclBuilder.swift | ||
| // Relay | ||
| // | ||
| // Created by Kamil Strzelecki on 12/01/2025. | ||
| // Copyright © 2025 Kamil Strzelecki. All rights reserved. | ||
| // | ||
|
|
||
| import SwiftSyntaxMacros | ||
|
|
||
| internal struct PropertyPublisherDeclBuilder: ClassDeclBuilder, MemberBuilding { | ||
|
|
||
| let declaration: ClassDeclSyntax | ||
| let properties: PropertiesList | ||
| let trimmedSuperclassType: TypeSyntax? | ||
| let preferredGlobalActorIsolation: GlobalActorIsolation? | ||
|
|
||
| func build() -> [DeclSyntax] { | ||
| [ | ||
| """ | ||
| \(inheritedGlobalActorIsolation)\(inheritedAccessControlLevelAllowingOpen)\(inheritedFinalModifier)\ | ||
| class PropertyPublisher: \(inheritanceClause()) { | ||
|
|
||
| private final unowned let object: \(trimmedType) | ||
|
|
||
| \(objectWillChangeDidChangePublishers()) | ||
|
|
||
| \(initializer()) | ||
|
|
||
| \(deinitializer()) | ||
|
|
||
| \(storedPropertiesPublishers().formatted()) | ||
|
|
||
| \(computedPropertiesPublishers().formatted()) | ||
|
|
||
| \(memoizedPropertiesPublishers().formatted()) | ||
| } | ||
| """ | ||
| ] | ||
| } | ||
|
|
||
| private func inheritanceClause() -> TypeSyntax { | ||
| if let trimmedSuperclassType { | ||
| "\(trimmedSuperclassType).PropertyPublisher" | ||
| } else { | ||
| "Relay.AnyPropertyPublisher" | ||
| } | ||
| } | ||
|
|
||
| private func objectWillChangeDidChangePublishers() -> MemberBlockItemListSyntax { | ||
| let notation = CamelCaseNotation(string: trimmedType.description) | ||
| let prefix = notation.joined(as: .lowerCamelCase) | ||
|
|
||
| return """ | ||
| \(inheritedAccessControlLevel)final var \ | ||
| \(raw: prefix)WillChange: some Publisher<\(trimmedType), Never> { | ||
| willChange.map { [unowned object] _ in | ||
| object | ||
| } | ||
| } | ||
|
|
||
| \(inheritedAccessControlLevel)final var \ | ||
| \(raw: prefix)DidChange: some Publisher<\(trimmedType), Never> { | ||
| didChange.map { [unowned object] _ in | ||
| object | ||
| } | ||
| } | ||
| """ | ||
| } | ||
|
|
||
| private func initializer() -> MemberBlockItemListSyntax { | ||
| """ | ||
| \(inheritedAccessControlLevel)init(object: \(trimmedType)) { | ||
| self.object = object | ||
| super.init(object: object) | ||
| } | ||
| """ | ||
| } | ||
|
|
||
| private func deinitializer() -> MemberBlockItemListSyntax { | ||
| """ | ||
| \(inheritedGlobalActorIsolation)deinit { | ||
| \(storedPropertiesSubjectsFinishCalls().formatted()) | ||
| } | ||
| """ | ||
| } | ||
|
|
||
| @CodeBlockItemListBuilder | ||
| private func storedPropertiesSubjectsFinishCalls() -> CodeBlockItemListSyntax { | ||
| for property in properties.all where property.isStoredPublisherTracked { | ||
| let call = storedPropertySubjectFinishCall(for: property) | ||
| if let ifConfigCall = property.underlying.applyingEnclosingIfConfig(to: call) { | ||
| ifConfigCall | ||
| } else { | ||
| call | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private func storedPropertySubjectFinishCall(for property: Property) -> CodeBlockItemListSyntax { | ||
| "_\(property.trimmedName).send(completion: .finished)" | ||
| } | ||
|
|
||
| @MemberBlockItemListBuilder | ||
| private func storedPropertiesPublishers() -> MemberBlockItemListSyntax { | ||
| for property in properties.all where property.isStoredPublisherTracked { | ||
| let publisher = storedPropertyPublisher(for: property) | ||
| if let ifConfigPublisher = property.underlying.applyingEnclosingIfConfig(to: publisher) { | ||
| ifConfigPublisher | ||
| } else { | ||
| publisher | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private func storedPropertyPublisher(for property: Property) -> MemberBlockItemListSyntax { | ||
| // Stored properties cannot be made potentially unavailable | ||
| let accessControlLevel = AccessControlLevel.forSibling(of: property.underlying) | ||
| let name = property.trimmedName | ||
| let type = property.inferredType | ||
|
|
||
| return """ | ||
| fileprivate final let _\(name) = PassthroughSubject<\(type), Never>() | ||
| \(accessControlLevel)final var \(name): some Publisher<\(type), Never> { | ||
| _storedPropertyPublisher(_\(name), for: \\.\(name), object: object) | ||
| } | ||
| """ | ||
| } | ||
|
|
||
| @MemberBlockItemListBuilder | ||
| private func computedPropertiesPublishers() -> MemberBlockItemListSyntax { | ||
| for property in properties.all where property.isComputedPublisherTracked { | ||
| let publisher = computedPropertyPublisher(for: property) | ||
| if let ifConfigPublisher = property.underlying.applyingEnclosingIfConfig(to: publisher) { | ||
| ifConfigPublisher | ||
| } else { | ||
| publisher | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private func computedPropertyPublisher(for property: Property) -> MemberBlockItemListSyntax { | ||
| let accessControlLevel = AccessControlLevel.forSibling(of: property.underlying) | ||
| let availability = property.availability?.trimmed.withTrailingNewline | ||
| let name = property.trimmedName | ||
| let type = property.inferredType | ||
|
|
||
| return """ | ||
| \(availability)\(accessControlLevel)final var \(name): some Publisher<\(type), Never> { | ||
| _computedPropertyPublisher(for: \\.\(name), object: object) | ||
| } | ||
| """ | ||
| } | ||
|
|
||
| @MemberBlockItemListBuilder | ||
| private func memoizedPropertiesPublishers() -> MemberBlockItemListSyntax { | ||
| for member in declaration.memberBlock.members { | ||
| if let extractionResult = MemoizedMacro.extract(from: member.decl) { | ||
| let declaration = extractionResult.declaration | ||
|
|
||
| if !declaration.attributes.contains(like: PublisherIgnoredMacro.attribute) { | ||
| let publisher = memoizedPropertyPublisher(for: extractionResult) | ||
| if let ifConfigPublisher = declaration.applyingEnclosingIfConfig(to: publisher) { | ||
| ifConfigPublisher | ||
| } else { | ||
| publisher | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| private func memoizedPropertyPublisher( | ||
| for extractionResult: MemoizedMacro.ExtractionResult | ||
| ) -> MemberBlockItemListSyntax { | ||
| let accessControlLevel = extractionResult.preferredAccessControlLevel?.inheritedBySibling() | ||
| let availability = extractionResult.declaration.availability?.trimmed.withTrailingNewline | ||
| let name = extractionResult.propertyName | ||
| let type = extractionResult.trimmedReturnType | ||
|
|
||
| return """ | ||
| \(availability)\(accessControlLevel)final var \(raw: name): some Publisher<\(type), Never> { | ||
| _computedPropertyPublisher(for: \\.\(raw: name), object: object) | ||
| } | ||
| """ | ||
| } | ||
| } |
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🌐 Web query:
GitHub Actions macos-26 runner Xcode 26.0 simulator versions available💡 Result:
On macos-26 the Xcode and simulator runtimes listed in the runner-images release notes are:
(See the GitHub Actions runner-images macOS-26 release notes for details and exact build paths.) [1][2]
Sources:
[1] actions/runner-images — macOS-26 release notes. [2] actions/runner-images README (Xcode simulator policy).
Critical: Specified Xcode and simulator versions do not exist on macos-26 runners.
The workflow specifies Xcode 26.0 and simulator OS versions 26.0/26.0.1, but GitHub Actions macos-26 runners only provide Xcode 26.1.1 (stable) and 26.2 (beta), with simulator runtimes limited to 26.1 and 26.2 for all platforms (iOS, tvOS, watchOS, visionOS). This configuration will cause CI failures. Update to an available version: either 26.1 or 26.2.
Also applies to: 91-91, 94-94, 97-97, 100-100
🤖 Prompt for AI Agents