Skip to content

Commit 987521f

Browse files
committed
Move to grpc-swift-2
Motivation: To support incremental migration, v2 has moved to the 'grpc-swift-2' package. Modifications: - Update dependencies - Update generated code - Re-baseline availability Result: Easier to migrate from gRPC Swift 1 to 2
1 parent 41ba003 commit 987521f

26 files changed

+102
-102
lines changed

Package.swift

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ let products: [Product] = [
4242

4343
let dependencies: [Package.Dependency] = [
4444
.package(
45-
url: "https://github.com/grpc/grpc-swift.git",
46-
from: "2.2.0"
45+
url: "https://github.com/grpc/grpc-swift-2.git",
46+
from: "2.0.0"
4747
),
4848
.package(
4949
url: "https://github.com/grpc/grpc-swift-protobuf.git",
50-
from: "1.3.0"
50+
from: "2.0.0"
5151
),
5252
.package(
5353
url: "https://github.com/apple/swift-protobuf.git",
@@ -65,12 +65,12 @@ let dependencies: [Package.Dependency] = [
6565

6666
// -------------------------------------------------------------------------------------------------
6767

68-
// This adds some build settings which allow us to map "@available(gRPCSwiftExtras 1.x, *)" to
68+
// This adds some build settings which allow us to map "@available(gRPCSwiftExtras 2.x, *)" to
6969
// the appropriate OS platforms.
7070
let nextMinorVersion = 1
7171
let availabilitySettings: [SwiftSetting] = (0 ... nextMinorVersion).map { minor in
7272
let name = "gRPCSwiftExtras"
73-
let version = "1.\(minor)"
73+
let version = "2.\(minor)"
7474
let platforms = "macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0"
7575
let setting = "AvailabilityMacro=\(name) \(version):\(platforms)"
7676
return .enableExperimentalFeature(setting)
@@ -91,7 +91,7 @@ let targets: [Target] = [
9191
.target(
9292
name: "GRPCHealthService",
9393
dependencies: [
94-
.product(name: "GRPCCore", package: "grpc-swift"),
94+
.product(name: "GRPCCore", package: "grpc-swift-2"),
9595
.product(name: "GRPCProtobuf", package: "grpc-swift-protobuf"),
9696
.product(name: "SwiftProtobuf", package: "swift-protobuf"),
9797
],
@@ -101,8 +101,8 @@ let targets: [Target] = [
101101
name: "GRPCHealthServiceTests",
102102
dependencies: [
103103
.target(name: "GRPCHealthService"),
104-
.product(name: "GRPCCore", package: "grpc-swift"),
105-
.product(name: "GRPCInProcessTransport", package: "grpc-swift"),
104+
.product(name: "GRPCCore", package: "grpc-swift-2"),
105+
.product(name: "GRPCInProcessTransport", package: "grpc-swift-2"),
106106
],
107107
swiftSettings: defaultSwiftSettings
108108
),
@@ -111,7 +111,7 @@ let targets: [Target] = [
111111
.target(
112112
name: "GRPCReflectionService",
113113
dependencies: [
114-
.product(name: "GRPCCore", package: "grpc-swift"),
114+
.product(name: "GRPCCore", package: "grpc-swift-2"),
115115
.product(name: "GRPCProtobuf", package: "grpc-swift-protobuf"),
116116
.product(name: "SwiftProtobuf", package: "swift-protobuf"),
117117
],
@@ -121,8 +121,8 @@ let targets: [Target] = [
121121
name: "GRPCReflectionServiceTests",
122122
dependencies: [
123123
.target(name: "GRPCReflectionService"),
124-
.product(name: "GRPCCore", package: "grpc-swift"),
125-
.product(name: "GRPCInProcessTransport", package: "grpc-swift"),
124+
.product(name: "GRPCCore", package: "grpc-swift-2"),
125+
.product(name: "GRPCInProcessTransport", package: "grpc-swift-2"),
126126
.product(name: "SwiftProtobuf", package: "swift-protobuf"),
127127
],
128128
resources: [
@@ -135,7 +135,7 @@ let targets: [Target] = [
135135
.target(
136136
name: "GRPCOTelTracingInterceptors",
137137
dependencies: [
138-
.product(name: "GRPCCore", package: "grpc-swift"),
138+
.product(name: "GRPCCore", package: "grpc-swift-2"),
139139
.product(name: "Tracing", package: "swift-distributed-tracing"),
140140
],
141141
swiftSettings: defaultSwiftSettings
@@ -144,7 +144,7 @@ let targets: [Target] = [
144144
name: "GRPCOTelTracingInterceptorsTests",
145145
dependencies: [
146146
.target(name: "GRPCOTelTracingInterceptors"),
147-
.product(name: "GRPCCore", package: "grpc-swift"),
147+
.product(name: "GRPCCore", package: "grpc-swift-2"),
148148
.product(name: "Tracing", package: "swift-distributed-tracing"),
149149
],
150150
swiftSettings: defaultSwiftSettings
@@ -154,7 +154,7 @@ let targets: [Target] = [
154154
.target(
155155
name: "GRPCServiceLifecycle",
156156
dependencies: [
157-
.product(name: "GRPCCore", package: "grpc-swift"),
157+
.product(name: "GRPCCore", package: "grpc-swift-2"),
158158
.product(name: "ServiceLifecycle", package: "swift-service-lifecycle"),
159159
],
160160
swiftSettings: defaultSwiftSettings
@@ -163,9 +163,9 @@ let targets: [Target] = [
163163
name: "GRPCServiceLifecycleTests",
164164
dependencies: [
165165
.target(name: "GRPCServiceLifecycle"),
166-
.product(name: "GRPCCore", package: "grpc-swift"),
166+
.product(name: "GRPCCore", package: "grpc-swift-2"),
167167
.product(name: "ServiceLifecycleTestKit", package: "swift-service-lifecycle"),
168-
.product(name: "GRPCInProcessTransport", package: "grpc-swift"),
168+
.product(name: "GRPCInProcessTransport", package: "grpc-swift-2"),
169169
],
170170
swiftSettings: defaultSwiftSettings
171171
),
@@ -174,7 +174,7 @@ let targets: [Target] = [
174174
.target(
175175
name: "GRPCInteropTests",
176176
dependencies: [
177-
.product(name: "GRPCCore", package: "grpc-swift"),
177+
.product(name: "GRPCCore", package: "grpc-swift-2"),
178178
.product(name: "GRPCProtobuf", package: "grpc-swift-protobuf"),
179179
],
180180
swiftSettings: defaultSwiftSettings
@@ -184,8 +184,8 @@ let targets: [Target] = [
184184
name: "InProcessInteropTests",
185185
dependencies: [
186186
.target(name: "GRPCInteropTests"),
187-
.product(name: "GRPCCore", package: "grpc-swift"),
188-
.product(name: "GRPCInProcessTransport", package: "grpc-swift"),
187+
.product(name: "GRPCCore", package: "grpc-swift-2"),
188+
.product(name: "GRPCInProcessTransport", package: "grpc-swift-2"),
189189
],
190190
swiftSettings: defaultSwiftSettings
191191
),

Sources/GRPCHealthService/HealthService+Service.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@
1717
internal import GRPCCore
1818
private import Synchronization
1919

20-
@available(gRPCSwiftExtras 1.0, *)
20+
@available(gRPCSwiftExtras 2.0, *)
2121
extension HealthService {
2222
internal struct Service: Grpc_Health_V1_Health.ServiceProtocol {
2323
private let state = Self.State()
2424
}
2525
}
2626

27-
@available(gRPCSwiftExtras 1.0, *)
27+
@available(gRPCSwiftExtras 2.0, *)
2828
extension HealthService.Service {
2929
func check(
3030
request: ServerRequest<Grpc_Health_V1_HealthCheckRequest>,
@@ -71,7 +71,7 @@ extension HealthService.Service {
7171
}
7272
}
7373

74-
@available(gRPCSwiftExtras 1.0, *)
74+
@available(gRPCSwiftExtras 2.0, *)
7575
extension HealthService.Service {
7676
private final class State: Sendable {
7777
// The state of each service keyed by the fully qualified service name.

Sources/GRPCHealthService/HealthService.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public import GRPCCore
4141
/// // ...
4242
/// }
4343
/// ```
44-
@available(gRPCSwiftExtras 1.0, *)
44+
@available(gRPCSwiftExtras 2.0, *)
4545
public struct HealthService: Sendable, RegistrableRPCService {
4646
/// An implementation of the `grpc.health.v1.Health` service.
4747
private let service: Service
@@ -63,7 +63,7 @@ public struct HealthService: Sendable, RegistrableRPCService {
6363
}
6464
}
6565

66-
@available(gRPCSwiftExtras 1.0, *)
66+
@available(gRPCSwiftExtras 2.0, *)
6767
extension HealthService {
6868
/// Provides status updates to ``HealthService``.
6969
public struct Provider: Sendable {
@@ -107,7 +107,7 @@ extension HealthService {
107107
}
108108
}
109109

110-
@available(gRPCSwiftExtras 1.0, *)
110+
@available(gRPCSwiftExtras 2.0, *)
111111
extension Grpc_Health_V1_HealthCheckResponse.ServingStatus {
112112
package init(_ status: ServingStatus) {
113113
switch status.value {

Sources/GRPCHealthService/ServingStatus.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
///
1919
/// - ``ServingStatus/serving`` indicates that a service is healthy.
2020
/// - ``ServingStatus/notServing`` indicates that a service is unhealthy.
21-
@available(gRPCSwiftExtras 1.0, *)
21+
@available(gRPCSwiftExtras 2.0, *)
2222
public struct ServingStatus: Sendable, Hashable {
2323
internal enum Value: Sendable, Hashable {
2424
case serving

Sources/GRPCInteropTests/AssertionFailure.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
/// Failure assertion for interoperability testing.
1818
///
1919
/// This is required because the tests must be able to run without XCTest.
20-
@available(gRPCSwiftExtras 1.0, *)
20+
@available(gRPCSwiftExtras 2.0, *)
2121
public struct AssertionFailure: Error {
2222
public var message: String
2323
public var file: String
@@ -31,7 +31,7 @@ public struct AssertionFailure: Error {
3131
}
3232

3333
/// Asserts that the value of an expression is `true`.
34-
@available(gRPCSwiftExtras 1.0, *)
34+
@available(gRPCSwiftExtras 2.0, *)
3535
public func assertTrue(
3636
_ expression: @autoclosure () throws -> Bool,
3737
_ message: String = "The statement is not true.",
@@ -44,7 +44,7 @@ public func assertTrue(
4444
}
4545

4646
/// Asserts that the two given values are equal.
47-
@available(gRPCSwiftExtras 1.0, *)
47+
@available(gRPCSwiftExtras 2.0, *)
4848
public func assertEqual<T: Equatable>(
4949
_ value1: T,
5050
_ value2: T,

Sources/GRPCInteropTests/InteroperabilityTestCase.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616
public import GRPCCore
1717

18-
@available(gRPCSwiftExtras 1.0, *)
18+
@available(gRPCSwiftExtras 2.0, *)
1919
public protocol InteroperabilityTest {
2020
/// Run a test case using the given connection.
2121
///
@@ -48,7 +48,7 @@ public protocol InteroperabilityTest {
4848
/// Note: Tests for compression have not been implemented yet as compression is
4949
/// not supported. Once the API which allows for compression will be implemented
5050
/// these tests should be added.
51-
@available(gRPCSwiftExtras 1.0, *)
51+
@available(gRPCSwiftExtras 2.0, *)
5252
public enum InteroperabilityTestCase: String, CaseIterable, Sendable {
5353
case emptyUnary = "empty_unary"
5454
case largeUnary = "large_unary"
@@ -70,7 +70,7 @@ public enum InteroperabilityTestCase: String, CaseIterable, Sendable {
7070
}
7171
}
7272

73-
@available(gRPCSwiftExtras 1.0, *)
73+
@available(gRPCSwiftExtras 2.0, *)
7474
extension InteroperabilityTestCase {
7575
/// Return a new instance of the test case.
7676
public func makeTest() -> any InteroperabilityTest {

Sources/GRPCInteropTests/InteroperabilityTestCases.swift

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ private import struct Foundation.Data
3636
/// Client asserts:
3737
/// - call was successful
3838
/// - response is non-null
39-
@available(gRPCSwiftExtras 1.0, *)
39+
@available(gRPCSwiftExtras 2.0, *)
4040
struct EmptyUnary: InteroperabilityTest {
4141
func run<Transport: ClientTransport>(client: GRPCClient<Transport>) async throws {
4242
let testServiceClient = Grpc_Testing_TestService.Client(wrapping: client)
@@ -70,7 +70,7 @@ struct EmptyUnary: InteroperabilityTest {
7070
/// - response payload body is 314159 bytes in size
7171
/// - clients are free to assert that the response payload body contents are zero and comparing
7272
/// the entire response message against a golden response
73-
@available(gRPCSwiftExtras 1.0, *)
73+
@available(gRPCSwiftExtras 2.0, *)
7474
struct LargeUnary: InteroperabilityTest {
7575
func run<Transport: ClientTransport>(client: GRPCClient<Transport>) async throws {
7676
let testServiceClient = Grpc_Testing_TestService.Client(wrapping: client)
@@ -146,7 +146,7 @@ struct LargeUnary: InteroperabilityTest {
146146
/// - Response payload body is 314159 bytes in size.
147147
/// - Clients are free to assert that the response payload body contents are zeros and comparing the
148148
/// entire response message against a golden response.
149-
@available(gRPCSwiftExtras 1.0, *)
149+
@available(gRPCSwiftExtras 2.0, *)
150150
class ClientCompressedUnary: InteroperabilityTest {
151151
func run<Transport: ClientTransport>(client: GRPCClient<Transport>) async throws {
152152
let testServiceClient = Grpc_Testing_TestService.Client(wrapping: client)
@@ -256,7 +256,7 @@ class ClientCompressedUnary: InteroperabilityTest {
256256
/// - response payload body is 314159 bytes in size in both cases.
257257
/// - clients are free to assert that the response payload body contents are zero and comparing the
258258
/// entire response message against a golden response
259-
@available(gRPCSwiftExtras 1.0, *)
259+
@available(gRPCSwiftExtras 2.0, *)
260260
class ServerCompressedUnary: InteroperabilityTest {
261261
func run<Transport: ClientTransport>(client: GRPCClient<Transport>) async throws {
262262
let testServiceClient = Grpc_Testing_TestService.Client(wrapping: client)
@@ -346,7 +346,7 @@ class ServerCompressedUnary: InteroperabilityTest {
346346
/// Client asserts:
347347
/// - call was successful
348348
/// - response aggregated_payload_size is 74922
349-
@available(gRPCSwiftExtras 1.0, *)
349+
@available(gRPCSwiftExtras 2.0, *)
350350
struct ClientStreaming: InteroperabilityTest {
351351
func run<Transport: ClientTransport>(client: GRPCClient<Transport>) async throws {
352352
let testServiceClient = Grpc_Testing_TestService.Client(wrapping: client)
@@ -397,7 +397,7 @@ struct ClientStreaming: InteroperabilityTest {
397397
/// - response payload bodies are sized (in order): 31415, 9, 2653, 58979
398398
/// - clients are free to assert that the response payload body contents are zero and
399399
/// comparing the entire response messages against golden responses
400-
@available(gRPCSwiftExtras 1.0, *)
400+
@available(gRPCSwiftExtras 2.0, *)
401401
struct ServerStreaming: InteroperabilityTest {
402402
func run<Transport: ClientTransport>(client: GRPCClient<Transport>) async throws {
403403
let testServiceClient = Grpc_Testing_TestService.Client(wrapping: client)
@@ -473,7 +473,7 @@ struct ServerStreaming: InteroperabilityTest {
473473
/// - response payload bodies are sized (in order): 31415, 92653
474474
/// - clients are free to assert that the response payload body contents are zero and comparing the
475475
/// entire response messages against golden responses
476-
@available(gRPCSwiftExtras 1.0, *)
476+
@available(gRPCSwiftExtras 2.0, *)
477477
class ServerCompressedStreaming: InteroperabilityTest {
478478
func run<Transport: ClientTransport>(client: GRPCClient<Transport>) async throws {
479479
let testServiceClient = Grpc_Testing_TestService.Client(wrapping: client)
@@ -586,7 +586,7 @@ class ServerCompressedStreaming: InteroperabilityTest {
586586
/// - response payload bodies are sized (in order): 31415, 9, 2653, 58979
587587
/// - clients are free to assert that the response payload body contents are zero and
588588
/// comparing the entire response messages against golden responses
589-
@available(gRPCSwiftExtras 1.0, *)
589+
@available(gRPCSwiftExtras 2.0, *)
590590
struct PingPong: InteroperabilityTest {
591591
func run<Transport: ClientTransport>(client: GRPCClient<Transport>) async throws {
592592
let testServiceClient = Grpc_Testing_TestService.Client(wrapping: client)
@@ -653,7 +653,7 @@ struct PingPong: InteroperabilityTest {
653653
/// Client asserts:
654654
/// - call was successful
655655
/// - exactly zero responses
656-
@available(gRPCSwiftExtras 1.0, *)
656+
@available(gRPCSwiftExtras 2.0, *)
657657
struct EmptyStream: InteroperabilityTest {
658658
func run<Transport: ClientTransport>(client: GRPCClient<Transport>) async throws {
659659
let testServiceClient = Grpc_Testing_TestService.Client(wrapping: client)
@@ -709,7 +709,7 @@ struct EmptyStream: InteroperabilityTest {
709709
/// received in the initial metadata for calls in Procedure steps 1 and 2.
710710
/// - metadata with key "x-grpc-test-echo-trailing-bin" and value 0xababab is received in the
711711
/// trailing metadata for calls in Procedure steps 1 and 2.
712-
@available(gRPCSwiftExtras 1.0, *)
712+
@available(gRPCSwiftExtras 2.0, *)
713713
struct CustomMetadata: InteroperabilityTest {
714714
let initialMetadataName = "x-grpc-test-echo-initial"
715715
let initialMetadataValue = "test_initial_metadata_value"
@@ -830,7 +830,7 @@ struct CustomMetadata: InteroperabilityTest {
830830
/// Client asserts:
831831
/// - received status code is the same as the sent code for both Procedure steps 1 and 2
832832
/// - received status message is the same as the sent message for both Procedure steps 1 and 2
833-
@available(gRPCSwiftExtras 1.0, *)
833+
@available(gRPCSwiftExtras 2.0, *)
834834
struct StatusCodeAndMessage: InteroperabilityTest {
835835
let expectedCode = 2
836836
let expectedMessage = "test status message"
@@ -908,7 +908,7 @@ struct StatusCodeAndMessage: InteroperabilityTest {
908908
/// - received status code is the same as the sent code for Procedure step 1
909909
/// - received status message is the same as the sent message for Procedure step 1, including all
910910
/// whitespace characters
911-
@available(gRPCSwiftExtras 1.0, *)
911+
@available(gRPCSwiftExtras 2.0, *)
912912
struct SpecialStatusMessage: InteroperabilityTest {
913913
func run<Transport: ClientTransport>(client: GRPCClient<Transport>) async throws {
914914
let testServiceClient = Grpc_Testing_TestService.Client(wrapping: client)
@@ -951,7 +951,7 @@ struct SpecialStatusMessage: InteroperabilityTest {
951951
///
952952
/// Client asserts:
953953
/// - received status code is 12 (UNIMPLEMENTED)
954-
@available(gRPCSwiftExtras 1.0, *)
954+
@available(gRPCSwiftExtras 2.0, *)
955955
struct UnimplementedMethod: InteroperabilityTest {
956956
func run<Transport: ClientTransport>(client: GRPCClient<Transport>) async throws {
957957
let testServiceClient = Grpc_Testing_TestService.Client(wrapping: client)
@@ -984,7 +984,7 @@ struct UnimplementedMethod: InteroperabilityTest {
984984
///
985985
/// Client asserts:
986986
/// - received status code is 12 (UNIMPLEMENTED)
987-
@available(gRPCSwiftExtras 1.0, *)
987+
@available(gRPCSwiftExtras 2.0, *)
988988
struct UnimplementedService: InteroperabilityTest {
989989
func run<Transport: ClientTransport>(client: GRPCClient<Transport>) async throws {
990990
let unimplementedServiceClient = Grpc_Testing_UnimplementedService.Client(wrapping: client)

Sources/GRPCInteropTests/TestService.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ private import struct FoundationEssentials.Data
2323
private import struct Foundation.Data
2424
#endif
2525

26-
@available(gRPCSwiftExtras 1.0, *)
26+
@available(gRPCSwiftExtras 2.0, *)
2727
public struct TestService: Grpc_Testing_TestService.ServiceProtocol {
2828
public init() {}
2929

@@ -234,7 +234,7 @@ public struct TestService: Grpc_Testing_TestService.ServiceProtocol {
234234
}
235235
}
236236

237-
@available(gRPCSwiftExtras 1.0, *)
237+
@available(gRPCSwiftExtras 2.0, *)
238238
extension Metadata {
239239
fileprivate func makeInitialAndTrailingMetadata() -> (Metadata, Metadata) {
240240
var initialMetadata = Metadata()

Sources/GRPCOTelTracingInterceptors/HookedAsyncSequence.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
@available(gRPCSwiftExtras 1.0, *)
17+
@available(gRPCSwiftExtras 2.0, *)
1818
internal struct HookedRPCAsyncSequence<Wrapped: AsyncSequence & Sendable>: AsyncSequence, Sendable
1919
where Wrapped.Element: Sendable {
2020
private let wrapped: Wrapped

0 commit comments

Comments
 (0)