Skip to content

Commit 91bdd63

Browse files
committed
support SPM
1 parent e66bdd2 commit 91bdd63

File tree

2 files changed

+56
-24
lines changed

2 files changed

+56
-24
lines changed

Package.swift

Lines changed: 55 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,94 @@
1-
// swift-tools-version: 5.9
1+
// swift-tools-version: 6.0
22
import CompilerPluginSupport
33
import PackageDescription
44

55
let package = Package(
66
name: "SmartCodable",
7-
platforms: [.macOS(.v10_15), .iOS(.v13), .tvOS(.v13), .watchOS(.v6), .macCatalyst(.v13), .visionOS(.v1)],
7+
platforms: [
8+
.macOS(.v10_15),
9+
.iOS(.v13),
10+
.tvOS(.v13),
11+
.watchOS(.v6),
12+
.macCatalyst(.v13),
13+
.visionOS(.v1)
14+
],
15+
816
products: [
9-
// Products define the executables and libraries a package produces, making them visible to other packages.
17+
// 纯运行时库,不依赖宏或 SwiftSyntax
1018
.library(
1119
name: "SmartCodable",
1220
targets: ["SmartCodable"]
1321
),
22+
23+
// 带继承/宏能力,依赖 SwiftSyntax
1424
.library(
1525
name: "SmartCodableInherit",
1626
targets: ["SmartCodableInherit"]
1727
)
1828
],
29+
1930
dependencies: [
20-
// Depend on the latest Swift 5.9 SwiftSyntax
21-
.package(url: "https://github.com/swiftlang/swift-syntax", "600.0.0"..<"700.0.0")
31+
// SwiftSyntax 只会被 macro target 使用
32+
// 注意:严格锁定版本,确保 Xcode26.3 / Swift6.1+ 可用
33+
.package(
34+
url: "https://github.com/apple/swift-syntax.git",
35+
from: "610.0.0"
36+
)
2237
],
38+
2339
targets: [
24-
// Targets are the basic building blocks of a package, defining a module or a test suite.
25-
// Targets can depend on other targets in this package and products from dependencies.
26-
// Macro implementation that performs the source transformation of a macro.
40+
// =========================
41+
// MARK: Runtime target (no macro)
42+
// =========================
43+
.target(
44+
name: "SmartCodable",
45+
path: "Sources/SmartCodable",
46+
exclude: ["MacroSupport"] // 运行时不需要 macro 文件
47+
),
48+
49+
// =========================
50+
// MARK: Macro target
51+
// =========================
2752
.macro(
2853
name: "SmartCodableMacros",
2954
dependencies: [
3055
.product(name: "SwiftSyntax", package: "swift-syntax"),
3156
.product(name: "SwiftSyntaxMacros", package: "swift-syntax"),
32-
.product(name: "SwiftOperators", package: "swift-syntax"),
33-
.product(name: "SwiftParser", package: "swift-syntax"),
34-
.product(name: "SwiftParserDiagnostics", package: "swift-syntax"),
3557
.product(name: "SwiftCompilerPlugin", package: "swift-syntax"),
36-
]
58+
.product(name: "SwiftSyntaxBuilder", package: "swift-syntax"),
59+
.product(name: "SwiftParser", package: "swift-syntax"),
60+
.product(name: "SwiftParserDiagnostics", package: "swift-syntax")
61+
],
62+
path: "Sources/SmartCodableMacros"
3763
),
3864

39-
// Library that exposes a macro as part of its API, which is used in client programs.
40-
.target(
41-
name: "SmartCodable",
42-
exclude: ["MacroSupport"]),
43-
65+
// =========================
66+
// MARK: Macro-enabled API target
67+
// =========================
4468
.target(
4569
name: "SmartCodableInherit",
4670
dependencies: [
71+
"SmartCodable",
4772
"SmartCodableMacros"
4873
],
49-
path: "Sources/SmartCodable/MacroSupport"),
50-
51-
// A test target used to develop the macro implementation.
74+
path: "Sources/SmartCodable/MacroSupport"
75+
),
76+
77+
// =========================
78+
// MARK: Test target
79+
// =========================
5280
.testTarget(
5381
name: "SmartCodableTests",
5482
dependencies: [
5583
"SmartCodable",
5684
"SmartCodableInherit",
5785
"SmartCodableMacros",
58-
.product(name: "SwiftSyntaxMacrosTestSupport", package: "swift-syntax"),
59-
]
60-
),
86+
.product(
87+
name: "SwiftSyntaxMacrosTestSupport",
88+
package: "swift-syntax"
89+
)
90+
],
91+
path: "Tests"
92+
)
6193
]
6294
)

SmartCodable.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
Pod::Spec.new do |s|
1414
s.name = 'SmartCodable'
15-
s.version = '6.0.1'
15+
s.version = '6.0.2'
1616
s.summary = 'Swift数据解析库'
1717

1818
s.homepage = 'https://github.com/iAmMccc/SmartCodable'

0 commit comments

Comments
 (0)