Skip to content

Commit 8d33562

Browse files
authored
Use Swift 6 mode on the plugin examples to ensure generated code compiles in this mode (#1740)
1 parent f554d76 commit 8d33562

File tree

4 files changed

+123
-26
lines changed

4 files changed

+123
-26
lines changed

PluginExamples/Package.swift

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version: 5.8
1+
// swift-tools-version: 6.0
22

33
import PackageDescription
44

@@ -7,23 +7,7 @@ let package = Package(
77
dependencies: [
88
.package(path: "../")
99
],
10-
targets: targets()
11-
)
12-
13-
private func targets() -> [Target] {
14-
var testDependencies: [Target.Dependency] = [
15-
.target(name: "Simple"),
16-
.target(name: "Nested"),
17-
.target(name: "Import"),
18-
]
19-
#if compiler(>=5.9)
20-
testDependencies.append(.target(name: "AccessLevelOnImport"))
21-
#endif
22-
var targets: [Target] = [
23-
.testTarget(
24-
name: "ExampleTests",
25-
dependencies: testDependencies
26-
),
10+
targets: [
2711
.target(
2812
name: "Simple",
2913
dependencies: [
@@ -51,9 +35,6 @@ private func targets() -> [Target] {
5135
.plugin(name: "SwiftProtobufPlugin", package: "swift-protobuf")
5236
]
5337
),
54-
]
55-
#if compiler(>=5.9)
56-
targets.append(
5738
.target(
5839
name: "AccessLevelOnImport",
5940
dependencies: [
@@ -65,8 +46,16 @@ private func targets() -> [Target] {
6546
plugins: [
6647
.plugin(name: "SwiftProtobufPlugin", package: "swift-protobuf")
6748
]
68-
)
69-
)
70-
#endif
71-
return targets
72-
}
49+
),
50+
.testTarget(
51+
name: "ExampleTests",
52+
dependencies: [
53+
.target(name: "Simple"),
54+
.target(name: "Nested"),
55+
.target(name: "Import"),
56+
.target(name: "AccessLevelOnImport"),
57+
]
58+
),
59+
],
60+
swiftLanguageModes: [.v6]
61+
)

PluginExamples/[email protected]

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// swift-tools-version: 5.8
2+
3+
import PackageDescription
4+
5+
let package = Package(
6+
name: "PluginExamples",
7+
dependencies: [
8+
.package(path: "../")
9+
],
10+
targets: [
11+
.testTarget(
12+
name: "ExampleTests",
13+
dependencies: [
14+
.target(name: "Simple"),
15+
.target(name: "Nested"),
16+
.target(name: "Import"),
17+
]
18+
),
19+
.target(
20+
name: "Simple",
21+
dependencies: [
22+
.product(name: "SwiftProtobuf", package: "swift-protobuf")
23+
],
24+
plugins: [
25+
.plugin(name: "SwiftProtobufPlugin", package: "swift-protobuf")
26+
]
27+
),
28+
.target(
29+
name: "Nested",
30+
dependencies: [
31+
.product(name: "SwiftProtobuf", package: "swift-protobuf")
32+
],
33+
plugins: [
34+
.plugin(name: "SwiftProtobufPlugin", package: "swift-protobuf")
35+
]
36+
),
37+
.target(
38+
name: "Import",
39+
dependencies: [
40+
.product(name: "SwiftProtobuf", package: "swift-protobuf")
41+
],
42+
plugins: [
43+
.plugin(name: "SwiftProtobufPlugin", package: "swift-protobuf")
44+
]
45+
),
46+
]
47+
)

PluginExamples/[email protected]

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// swift-tools-version: 5.9
2+
3+
import PackageDescription
4+
5+
let package = Package(
6+
name: "PluginExamples",
7+
dependencies: [
8+
.package(path: "../")
9+
],
10+
targets: [
11+
.target(
12+
name: "Simple",
13+
dependencies: [
14+
.product(name: "SwiftProtobuf", package: "swift-protobuf")
15+
],
16+
plugins: [
17+
.plugin(name: "SwiftProtobufPlugin", package: "swift-protobuf")
18+
]
19+
),
20+
.target(
21+
name: "Nested",
22+
dependencies: [
23+
.product(name: "SwiftProtobuf", package: "swift-protobuf")
24+
],
25+
plugins: [
26+
.plugin(name: "SwiftProtobufPlugin", package: "swift-protobuf")
27+
]
28+
),
29+
.target(
30+
name: "Import",
31+
dependencies: [
32+
.product(name: "SwiftProtobuf", package: "swift-protobuf")
33+
],
34+
plugins: [
35+
.plugin(name: "SwiftProtobufPlugin", package: "swift-protobuf")
36+
]
37+
),
38+
.target(
39+
name: "AccessLevelOnImport",
40+
dependencies: [
41+
.product(name: "SwiftProtobuf", package: "swift-protobuf")
42+
],
43+
swiftSettings: [
44+
.enableExperimentalFeature("AccessLevelOnImport")
45+
],
46+
plugins: [
47+
.plugin(name: "SwiftProtobufPlugin", package: "swift-protobuf")
48+
]
49+
),
50+
.testTarget(
51+
name: "ExampleTests",
52+
dependencies: [
53+
.target(name: "Simple"),
54+
.target(name: "Nested"),
55+
.target(name: "Import"),
56+
.target(name: "AccessLevelOnImport"),
57+
]
58+
),
59+
]
60+
)

PluginExamples/Sources/Nested/Nested/Nested.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ syntax = "proto3";
22

33
message Nested {
44
string name = 1;
5+
Nested next = 2;
56
}

0 commit comments

Comments
 (0)