From 2b12e3ad0e2f3091fe0b18c1d6704d711b5e8ada Mon Sep 17 00:00:00 2001 From: mlch911 Date: Mon, 1 Dec 2025 11:24:12 +0800 Subject: [PATCH 1/3] be able to run test --- Package.swift | 135 +++++++++++------- .../QuickLayout/QuickLayout/QuickLayout.swift | 2 + 2 files changed, 84 insertions(+), 53 deletions(-) diff --git a/Package.swift b/Package.swift index e308ca1..d41d08a 100644 --- a/Package.swift +++ b/Package.swift @@ -10,72 +10,101 @@ import CompilerPluginSupport import PackageDescription -let package = Package( - name: "QuickLayout", - platforms: [ - .iOS(.v15), - .macOS(.v10_15), - ], - products: [ +#if os(iOS) || !os(macOS) +var QuickLayoutDependencies: [Target.Dependency] = [ + "QuickLayoutMacro", + "QuickLayoutBridge", +] +#else +var QuickLayoutDependencies: [Target.Dependency] = [ + "QuickLayoutMacro", +] +#endif + +var targets: [Target] = [ + .target( + name: "QuickLayout", + dependencies: QuickLayoutDependencies, + path: "Sources/QuickLayout/QuickLayout", + exclude: [ + "__showcase__/" + ] + ), + .macro( + name: "QuickLayoutMacro", + dependencies: [ + .product(name: "SwiftSyntaxMacros", package: "swift-syntax"), + .product(name: "SwiftCompilerPlugin", package: "swift-syntax"), + ], + path: "Sources/QuickLayout/QuickLayoutMacro" + ), + .target( + name: "FastResultBuilder", + path: "Sources/FastResultBuilder/FastResultBuilder", + exclude: [ + "__tests__/" + ] + ), + .testTarget( + name: "QuickLayoutMacroTests", + dependencies: [ + "QuickLayoutMacro", + .product(name: "SwiftSyntaxMacrosTestSupport", package: "swift-syntax"), + ], + path: "Sources/QuickLayout/QuickLayoutMacroTests" + ), +] + +var products: [Product] = [ .library( name: "QuickLayout", targets: ["QuickLayout"] ), - .library( - name: "QuickLayoutCore", - targets: ["QuickLayoutCore"] - ), .library( name: "FastResultBuilder", targets: ["FastResultBuilder"] ), +] + +// iOS-only targets +#if os(iOS) || !os(macOS) +targets += [ + .target( + name: "QuickLayoutCore", + path: "Sources/QuickLayout/QuickLayoutCore" + ), + .target( + name: "QuickLayoutBridge", + dependencies: ["FastResultBuilder", "QuickLayoutCore"], + path: "Sources/QuickLayout/QuickLayoutBridge", + exclude: [ + "__server_snapshot_tests__", + "__tests__", + ] + ), +] + +products += [ + .library( + name: "QuickLayoutCore", + targets: ["QuickLayoutCore"] + ), .library( name: "QuickLayoutBridge", targets: ["QuickLayoutBridge"] ), +] +#endif + +let package = Package( + name: "QuickLayout", + platforms: [ + .iOS(.v15), + .macOS(.v10_15), ], + products: products, dependencies: [ - .package(url: "https://github.com/apple/swift-syntax.git", from: "600.0.0") - ], - targets: [ - .target( - name: "QuickLayout", - dependencies: [ - "QuickLayoutMacro", - "QuickLayoutBridge", - ], - path: "Sources/QuickLayout/QuickLayout", - exclude: [ - "__showcase__/" - ] - ), - .macro( - name: "QuickLayoutMacro", - dependencies: [ - .product(name: "SwiftSyntaxMacros", package: "swift-syntax"), - .product(name: "SwiftCompilerPlugin", package: "swift-syntax"), - ], - path: "Sources/QuickLayout/QuickLayoutMacro", - ), - .target( - name: "QuickLayoutCore", - path: "Sources/QuickLayout/QuickLayoutCore", - ), - .target( - name: "FastResultBuilder", - path: "Sources/FastResultBuilder/FastResultBuilder", - exclude: [ - "__tests__/" - ] - ), - .target( - name: "QuickLayoutBridge", - dependencies: ["FastResultBuilder", "QuickLayoutCore"], - path: "Sources/QuickLayout/QuickLayoutBridge", - exclude: [ - "__server_snapshot_tests__", - "__tests__", - ] - ), + .package(url: "https://github.com/apple/swift-syntax.git", from: "602.0.0"), ], + targets: targets ) diff --git a/Sources/QuickLayout/QuickLayout/QuickLayout.swift b/Sources/QuickLayout/QuickLayout/QuickLayout.swift index c9d63d9..cf4e5cf 100644 --- a/Sources/QuickLayout/QuickLayout/QuickLayout.swift +++ b/Sources/QuickLayout/QuickLayout/QuickLayout.swift @@ -5,4 +5,6 @@ * LICENSE file in the root directory of this source tree. */ +#if canImport(QuickLayoutBridge) @_exported import QuickLayoutBridge +#endif From 88e39a724d4f84ed8cd018f31c1de2587831ed6f Mon Sep 17 00:00:00 2001 From: mlch911 Date: Mon, 1 Dec 2025 15:59:38 +0800 Subject: [PATCH 2/3] fix --- Package.swift | 145 +++++++++++++++++++++----------------------------- 1 file changed, 60 insertions(+), 85 deletions(-) diff --git a/Package.swift b/Package.swift index d41d08a..752b55e 100644 --- a/Package.swift +++ b/Package.swift @@ -10,52 +10,13 @@ import CompilerPluginSupport import PackageDescription -#if os(iOS) || !os(macOS) -var QuickLayoutDependencies: [Target.Dependency] = [ - "QuickLayoutMacro", - "QuickLayoutBridge", -] -#else -var QuickLayoutDependencies: [Target.Dependency] = [ - "QuickLayoutMacro", -] -#endif - -var targets: [Target] = [ - .target( - name: "QuickLayout", - dependencies: QuickLayoutDependencies, - path: "Sources/QuickLayout/QuickLayout", - exclude: [ - "__showcase__/" - ] - ), - .macro( - name: "QuickLayoutMacro", - dependencies: [ - .product(name: "SwiftSyntaxMacros", package: "swift-syntax"), - .product(name: "SwiftCompilerPlugin", package: "swift-syntax"), - ], - path: "Sources/QuickLayout/QuickLayoutMacro" - ), - .target( - name: "FastResultBuilder", - path: "Sources/FastResultBuilder/FastResultBuilder", - exclude: [ - "__tests__/" - ] - ), - .testTarget( - name: "QuickLayoutMacroTests", - dependencies: [ - "QuickLayoutMacro", - .product(name: "SwiftSyntaxMacrosTestSupport", package: "swift-syntax"), - ], - path: "Sources/QuickLayout/QuickLayoutMacroTests" - ), -] - -var products: [Product] = [ +let package = Package( + name: "QuickLayout", + platforms: [ + .iOS(.v15), + .macOS(.v10_15), + ], + products: [ .library( name: "QuickLayout", targets: ["QuickLayout"] @@ -64,47 +25,61 @@ var products: [Product] = [ name: "FastResultBuilder", targets: ["FastResultBuilder"] ), -] - -// iOS-only targets -#if os(iOS) || !os(macOS) -targets += [ - .target( - name: "QuickLayoutCore", - path: "Sources/QuickLayout/QuickLayoutCore" - ), - .target( - name: "QuickLayoutBridge", - dependencies: ["FastResultBuilder", "QuickLayoutCore"], - path: "Sources/QuickLayout/QuickLayoutBridge", - exclude: [ - "__server_snapshot_tests__", - "__tests__", - ] - ), -] - -products += [ - .library( - name: "QuickLayoutCore", - targets: ["QuickLayoutCore"] - ), - .library( - name: "QuickLayoutBridge", - targets: ["QuickLayoutBridge"] - ), -] -#endif - -let package = Package( - name: "QuickLayout", - platforms: [ - .iOS(.v15), - .macOS(.v10_15), ], - products: products, dependencies: [ .package(url: "https://github.com/apple/swift-syntax.git", from: "602.0.0"), + .package(url: "https://github.com/pointfreeco/swift-macro-testing.git", from: "0.6.4"), ], - targets: targets + targets: [ + .target( + name: "QuickLayout", + dependencies: [ + "QuickLayoutMacro", + .target(name: "QuickLayoutBridge", condition: .when(platforms: [.iOS])), + ], + path: "Sources/QuickLayout/QuickLayout", + exclude: [ + "__showcase__/" + ] + ), + .macro( + name: "QuickLayoutMacro", + dependencies: [ + .product(name: "SwiftSyntaxMacros", package: "swift-syntax"), + .product(name: "SwiftCompilerPlugin", package: "swift-syntax"), + ], + path: "Sources/QuickLayout/QuickLayoutMacro" + ), + .target( + name: "QuickLayoutCore", + path: "Sources/QuickLayout/QuickLayoutCore" + ), + .target( + name: "FastResultBuilder", + path: "Sources/FastResultBuilder/FastResultBuilder", + exclude: [ + "__tests__/" + ] + ), + .target( + name: "QuickLayoutBridge", + dependencies: [ + "FastResultBuilder", + .target(name: "QuickLayoutCore", condition: .when(platforms: [.iOS])), + ], + path: "Sources/QuickLayout/QuickLayoutBridge", + exclude: [ + "__server_snapshot_tests__", + "__tests__", + ] + ), + .testTarget( + name: "QuickLayoutMacroTests", + dependencies: [ + "QuickLayoutMacro", + .product(name: "SwiftSyntaxMacrosTestSupport", package: "swift-syntax"), + ], + path: "Sources/QuickLayout/QuickLayoutMacroTests" + ) + ] ) From 8dbe747ed08f755177651d1071cfdda9285be977 Mon Sep 17 00:00:00 2001 From: mlch911 Date: Mon, 1 Dec 2025 16:58:08 +0800 Subject: [PATCH 3/3] add ci --- .github/workflows/test.yml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..4e4e097 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,27 @@ +name: Tests + +on: + pull_request: + branches: + - main + push: + branches: + - main + +jobs: + build-and-test: + runs-on: macos-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set up Swift + uses: swift-actions/setup-swift@v2 + with: + swift-version: '6.0' + + - name: Build + run: swift build --build-tests + + - name: Run tests + run: swift test