diff --git a/.github/workflows/tvos-tests.yml b/.github/workflows/tvos-tests.yml index 401a874..c08e77c 100644 --- a/.github/workflows/tvos-tests.yml +++ b/.github/workflows/tvos-tests.yml @@ -42,7 +42,7 @@ jobs: run: | set -o pipefail && \ NSUnbufferedIO=YES \ - xcrun xcodebuild build -workspace . -scheme Vexil-Package -skipMacroValidation -destination "platform=tvOS Simulator,name=Apple TV 4K (3rd generation)" \ + xcrun xcodebuild build -workspace . -scheme Vexil-Package -skipMacroValidation -destination "generic/platform=tvOS Simulator" \ | xcbeautify --renderer github-actions build-tvos: diff --git a/Package.resolved b/Package.resolved index 044bf93..ae8f713 100644 --- a/Package.resolved +++ b/Package.resolved @@ -1,5 +1,5 @@ { - "originHash" : "7724a377457178ce875fe18adc9a76467dd42003b108c81973a2c98f158d4aef", + "originHash" : "28f3aa4d47ce18babb59fc2624554f373236e7d4bde940ac380abb401af9e84a", "pins" : [ { "identity" : "swift-async-algorithms", @@ -24,8 +24,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/swiftlang/swift-syntax.git", "state" : { - "revision" : "0687f71944021d616d34d922343dcef086855920", - "version" : "600.0.1" + "revision" : "050f1a346fbbac0ca2cfb15a95274f7bd1cf0ccf", + "version" : "604.0.0" } }, { diff --git a/Package.swift b/Package.swift index 57a9a60..4f73ee4 100644 --- a/Package.swift +++ b/Package.swift @@ -21,7 +21,7 @@ let package = Package( dependencies: [ .package(url: "https://github.com/apple/swift-async-algorithms.git", from: "1.0.0"), .package(url: "https://github.com/nicklockwood/SwiftFormat.git", from: "0.60.1"), - .package(url: "https://github.com/swiftlang/swift-syntax.git", "600.0.0" ..< "604.0.0"), + .package(url: "https://github.com/swiftlang/swift-syntax.git", "600.0.0" ..< "605.0.0"), ], targets: [ diff --git a/Sources/VexilMacros/FlagContainerMacro.swift b/Sources/VexilMacros/FlagContainerMacro.swift index de4c779..74e0c41 100644 --- a/Sources/VexilMacros/FlagContainerMacro.swift +++ b/Sources/VexilMacros/FlagContainerMacro.swift @@ -67,9 +67,7 @@ extension FlagContainerMacro: ExtensionMacro { conformingTo protocols: [TypeSyntax], in context: some MacroExpansionContext, ) throws -> [ExtensionDeclSyntax] { - var shouldGenerateConformance = protocols.isEmpty && ProcessInfo.processInfo.environment["XCTestConfigurationFilePath"] != nil - ? node.shouldGenerateConformance - : protocols.shouldGenerateConformance + var shouldGenerateConformance = protocols.shouldGenerateConformance // Check if the user has disabled Equatable conformance manually if @@ -79,8 +77,7 @@ extension FlagContainerMacro: ExtensionMacro { shouldGenerateConformance.equatable = false } - // Check that conformance doesn't already exist, or that we are inside a unit test. - // The latter is a workaround for https://github.com/apple/swift-syntax/issues/2031 + // Check that conformance doesn't already exist guard shouldGenerateConformance.flagContainer else { return [] } @@ -239,15 +236,3 @@ private extension [TypeSyntax] { } } - -private extension AttributeSyntax { - - var shouldGenerateConformance: (flagContainer: Bool, equatable: Bool, sendable: Bool) { - if attributeName.identifier == "FlagContainer" { - (true, true, true) - } else { - (false, false, false) - } - } - -} diff --git a/Sources/Vexillographer/FlagControl/FlagTextField+FloatingPoint.swift b/Sources/Vexillographer/FlagControl/FlagTextField+FloatingPoint.swift index 80529bd..97dfb1d 100644 --- a/Sources/Vexillographer/FlagControl/FlagTextField+FloatingPoint.swift +++ b/Sources/Vexillographer/FlagControl/FlagTextField+FloatingPoint.swift @@ -18,13 +18,13 @@ import Vexil extension FlagTextField where Value.BoxedValueType: BinaryFloatingPoint { init(configuration: FlagControlConfiguration) { - self = Self( + self.init( configuration: configuration, formatted: \.asString, editingFormat: { $0 }, ) #if os(iOS) || os(tvOS) - .keyboardType(.decimalPad) + keyboardType = .decimalPad #endif } @@ -56,13 +56,13 @@ extension FlagControlConfiguration: FloatingPointTextFieldRepresentable where Va extension FlagTextField { init(configuration: FlagControlConfiguration) where Value == Wrapped?, Wrapped.BoxedValueType: BinaryFloatingPoint { - self = Self( + self.init( configuration: configuration, formatted: \.asStringOrEmpty, editingFormat: { $0 }, ) #if os(iOS) || os(tvOS) - .keyboardType(.decimalPad) + keyboardType = .decimalPad #endif } diff --git a/Sources/Vexillographer/FlagControl/FlagTextField+Integer.swift b/Sources/Vexillographer/FlagControl/FlagTextField+Integer.swift index befd298..5cd9294 100644 --- a/Sources/Vexillographer/FlagControl/FlagTextField+Integer.swift +++ b/Sources/Vexillographer/FlagControl/FlagTextField+Integer.swift @@ -18,13 +18,13 @@ import Vexil extension FlagTextField where Value.BoxedValueType: BinaryInteger { init(configuration: FlagControlConfiguration) { - self = Self( + self.init( configuration: configuration, formatted: \.asString, editingFormat: { $0.filter(\.isNumber) }, ) #if os(iOS) || os(tvOS) - .keyboardType(.numberPad) + keyboardType = .numberPad #endif } @@ -56,13 +56,13 @@ extension FlagControlConfiguration: IntegerFlagTextFieldRepresentable where Valu extension FlagTextField { init(configuration: FlagControlConfiguration) where Value == Wrapped?, Wrapped.BoxedValueType: BinaryInteger { - self = Self( + self.init( configuration: configuration, formatted: \.asStringOrEmpty, editingFormat: { $0.filter(\.isNumber) }, ) #if os(iOS) || os(tvOS) - .keyboardType(.numberPad) + keyboardType = .numberPad #endif } diff --git a/Sources/Vexillographer/FlagControl/FlagTextField.swift b/Sources/Vexillographer/FlagControl/FlagTextField.swift index 4f95764..bf85a6b 100644 --- a/Sources/Vexillographer/FlagControl/FlagTextField.swift +++ b/Sources/Vexillographer/FlagControl/FlagTextField.swift @@ -27,7 +27,7 @@ struct FlagTextField: View { private var format: (String) -> String private var editingFormat: (String) -> String #if os(iOS) || os(tvOS) - private var keyboardType = UIKeyboardType.default + var keyboardType = UIKeyboardType.default #endif @State diff --git a/Tests/VexilMacroTests/EquatableFlagContainerMacroTests.swift b/Tests/VexilMacroTests/EquatableFlagContainerMacroTests.swift index 005feb9..5285969 100644 --- a/Tests/VexilMacroTests/EquatableFlagContainerMacroTests.swift +++ b/Tests/VexilMacroTests/EquatableFlagContainerMacroTests.swift @@ -13,6 +13,7 @@ #if canImport(VexilMacros) +import SwiftSyntaxMacroExpansion import SwiftSyntaxMacros import SwiftSyntaxMacrosTestSupport import VexilMacros @@ -60,8 +61,8 @@ final class EquatableFlagContainerMacroTests: XCTestCase { extension TestFlags: Sendable { } """, - macros: [ - "FlagContainer": FlagContainerMacro.self, + macroSpecs: [ + "FlagContainer": MacroSpec(type: FlagContainerMacro.self, conformances: ["FlagContainer", "Equatable", "Sendable"]), ], ) } @@ -163,9 +164,9 @@ final class EquatableFlagContainerMacroTests: XCTestCase { extension TestFlags: Sendable { } """, - macros: [ - "FlagContainer": FlagContainerMacro.self, - "Flag": FlagMacro.self, + macroSpecs: [ + "FlagContainer": MacroSpec(type: FlagContainerMacro.self, conformances: ["FlagContainer", "Equatable", "Sendable"]), + "Flag": MacroSpec(type: FlagMacro.self), ], ) } @@ -241,9 +242,9 @@ final class EquatableFlagContainerMacroTests: XCTestCase { extension TestFlags: Sendable { } """, - macros: [ - "FlagContainer": FlagContainerMacro.self, - "Flag": FlagMacro.self, + macroSpecs: [ + "FlagContainer": MacroSpec(type: FlagContainerMacro.self, conformances: ["FlagContainer", "Equatable", "Sendable"]), + "Flag": MacroSpec(type: FlagMacro.self), ], ) } @@ -322,9 +323,9 @@ final class EquatableFlagContainerMacroTests: XCTestCase { extension SomeContainer.TestFlags: Sendable { } """, - macros: [ - "FlagContainer": FlagContainerMacro.self, - "Flag": FlagMacro.self, + macroSpecs: [ + "FlagContainer": MacroSpec(type: FlagContainerMacro.self, conformances: ["FlagContainer", "Equatable", "Sendable"]), + "Flag": MacroSpec(type: FlagMacro.self), ], ) } @@ -399,9 +400,9 @@ final class EquatableFlagContainerMacroTests: XCTestCase { extension TestFlags: Sendable { } """, - macros: [ - "FlagContainer": FlagContainerMacro.self, - "Flag": FlagMacro.self, + macroSpecs: [ + "FlagContainer": MacroSpec(type: FlagContainerMacro.self, conformances: ["FlagContainer", "Equatable", "Sendable"]), + "Flag": MacroSpec(type: FlagMacro.self), ], ) } @@ -497,8 +498,8 @@ final class EquatableFlagContainerMacroTests: XCTestCase { extension TestFlags: Sendable { } """, - macros: [ - "FlagContainer": FlagContainerMacro.self, + macroSpecs: [ + "FlagContainer": MacroSpec(type: FlagContainerMacro.self, conformances: ["FlagContainer", "Equatable", "Sendable"]), ], ) } @@ -594,8 +595,8 @@ final class EquatableFlagContainerMacroTests: XCTestCase { extension TestFlags: Sendable { } """, - macros: [ - "FlagContainer": FlagContainerMacro.self, + macroSpecs: [ + "FlagContainer": MacroSpec(type: FlagContainerMacro.self, conformances: ["FlagContainer", "Equatable", "Sendable"]), ], ) } diff --git a/Tests/VexilMacroTests/FlagContainerMacroTests.swift b/Tests/VexilMacroTests/FlagContainerMacroTests.swift index 6cbadb3..6a3f34c 100644 --- a/Tests/VexilMacroTests/FlagContainerMacroTests.swift +++ b/Tests/VexilMacroTests/FlagContainerMacroTests.swift @@ -13,6 +13,7 @@ #if canImport(VexilMacros) +import SwiftSyntaxMacroExpansion import SwiftSyntaxMacros import SwiftSyntaxMacrosTestSupport import VexilMacros @@ -60,8 +61,8 @@ final class FlagContainerMacroTests: XCTestCase { extension TestFlags: Sendable { } """, - macros: [ - "FlagContainer": FlagContainerMacro.self, + macroSpecs: [ + "FlagContainer": MacroSpec(type: FlagContainerMacro.self, conformances: ["FlagContainer", "Equatable", "Sendable"]), ], ) } @@ -106,8 +107,8 @@ final class FlagContainerMacroTests: XCTestCase { extension TestFlags: Sendable { } """, - macros: [ - "FlagContainer": FlagContainerMacro.self, + macroSpecs: [ + "FlagContainer": MacroSpec(type: FlagContainerMacro.self, conformances: ["FlagContainer", "Equatable", "Sendable"]), ], ) } @@ -152,8 +153,8 @@ final class FlagContainerMacroTests: XCTestCase { extension TestFlags: Sendable { } """, - macros: [ - "FlagContainer": FlagContainerMacro.self, + macroSpecs: [ + "FlagContainer": MacroSpec(type: FlagContainerMacro.self, conformances: ["FlagContainer", "Equatable", "Sendable"]), ], ) } @@ -251,8 +252,8 @@ final class FlagContainerMacroTests: XCTestCase { extension TestFlags: Sendable { } """, - macros: [ - "FlagContainer": FlagContainerMacro.self, + macroSpecs: [ + "FlagContainer": MacroSpec(type: FlagContainerMacro.self, conformances: ["FlagContainer", "Equatable", "Sendable"]), ], ) }