Skip to content

Commit 3b6a69e

Browse files
authored
Fix compile issues in Google/NaturalLanguage (#643)
Motivation: The NaturalLanguage example did not compile because of breaking API changes between pre-release version. Modifications: Fix compilation issues. Result: NaturalLanguage example compiles.
1 parent 7ce29cb commit 3b6a69e

File tree

12 files changed

+5328
-65
lines changed

12 files changed

+5328
-65
lines changed

Examples/Google/NaturalLanguage/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ all:
33
swift build -c release
44
cp .build/release/NaturalLanguage .
55

6-
clean :
6+
clean:
77
rm -rf Packages googleapis .build
88
rm -f Package.pins NaturalLanguage Sources/*.pb.swift Sources/*.grpc.swift google.json
99
rm -rf Package.resolved

Examples/Google/NaturalLanguage/Package.resolved

Lines changed: 97 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Examples/Google/NaturalLanguage/Package.swift

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,18 @@ let package = Package(
2020
name: "NaturalLanguage",
2121
dependencies: [
2222
.package(url: "../../..", .branch("HEAD")),
23-
.package(url: "https://github.com/apple/swift-protobuf.git", from: "1.0.2"),
24-
.package(url: "https://github.com/kylef/Commander.git", from: "0.8.0"),
23+
.package(url: "https://github.com/apple/swift-protobuf.git", from: "1.7.0"),
2524
.package(url: "https://github.com/googleapis/google-auth-library-swift.git", from: "0.5.0")
2625
],
2726
targets: [
28-
.target(name: "NaturalLanguage",
29-
dependencies: [
30-
"GRPC",
31-
"SwiftProtobuf",
32-
"Commander",
33-
"OAuth2"],
34-
path: "Sources")
35-
])
27+
.target(
28+
name: "NaturalLanguage",
29+
dependencies: [
30+
"GRPC",
31+
"SwiftProtobuf",
32+
"OAuth2"
33+
],
34+
path: "Sources"
35+
)
36+
]
37+
)

Examples/Google/NaturalLanguage/RUNME

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,18 @@ if [ ! -d "googleapis" ]; then
1515
fi
1616

1717
protoc \
18-
google/cloud/language/v1/language_service.proto \
18+
google/cloud/language/v1/language_service.proto \
1919
google/api/annotations.proto \
2020
google/api/http.proto \
2121
google/protobuf/descriptor.proto \
22-
-Igoogleapis \
22+
-Igoogleapis \
2323
-I../common/include \
2424
--swift_out=googleapis \
2525
--grpc-swift_out=googleapis
2626

27-
# move Swift files to the Sources directory
28-
find googleapis -name "*.swift" -exec mv {} Sources \;
27+
# Move Swift files to the Sources directory. descriptor.pb.swift is provided
28+
# with SwiftProtobuf (from 1.7.0).
29+
find googleapis \
30+
-name "*.swift" \
31+
! -name "descriptor.pb.swift" \
32+
-exec mv {} Sources \;
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
// DO NOT EDIT.
2+
//
3+
// Generated by the Swift generator plugin for the protocol buffer compiler.
4+
// Source: google/api/annotations.proto
5+
//
6+
// For information on using the generated types, please see the documentation:
7+
// https://github.com/apple/swift-protobuf/
8+
9+
// Copyright (c) 2015, Google Inc.
10+
//
11+
// Licensed under the Apache License, Version 2.0 (the "License");
12+
// you may not use this file except in compliance with the License.
13+
// You may obtain a copy of the License at
14+
//
15+
// http://www.apache.org/licenses/LICENSE-2.0
16+
//
17+
// Unless required by applicable law or agreed to in writing, software
18+
// distributed under the License is distributed on an "AS IS" BASIS,
19+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20+
// See the License for the specific language governing permissions and
21+
// limitations under the License.
22+
23+
import Foundation
24+
import SwiftProtobuf
25+
26+
// If the compiler emits an error on this type, it is because this file
27+
// was generated by a version of the `protoc` Swift plug-in that is
28+
// incompatible with the version of SwiftProtobuf to which you are linking.
29+
// Please ensure that your are building against the same version of the API
30+
// that was used to generate this file.
31+
fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck {
32+
struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {}
33+
typealias Version = _2
34+
}
35+
36+
// MARK: - Extension support defined in annotations.proto.
37+
38+
extension SwiftProtobuf.Google_Protobuf_MethodOptions {
39+
40+
/// See `HttpRule`.
41+
var Google_Api_http: Google_Api_HttpRule {
42+
get {return getExtensionValue(ext: Google_Api_Extensions_http) ?? Google_Api_HttpRule()}
43+
set {setExtensionValue(ext: Google_Api_Extensions_http, value: newValue)}
44+
}
45+
/// Returns true if extension `Google_Api_Extensions_http`
46+
/// has been explicitly set.
47+
var hasGoogle_Api_http: Bool {
48+
return hasExtensionValue(ext: Google_Api_Extensions_http)
49+
}
50+
/// Clears the value of extension `Google_Api_Extensions_http`.
51+
/// Subsequent reads from it will return its default value.
52+
mutating func clearGoogle_Api_http() {
53+
clearExtensionValue(ext: Google_Api_Extensions_http)
54+
}
55+
56+
}
57+
58+
/// A `SwiftProtobuf.SimpleExtensionMap` that includes all of the extensions defined by
59+
/// this .proto file. It can be used any place an `SwiftProtobuf.ExtensionMap` is needed
60+
/// in parsing, or it can be combined with other `SwiftProtobuf.SimpleExtensionMap`s to create
61+
/// a larger `SwiftProtobuf.SimpleExtensionMap`.
62+
let Google_Api_Annotations_Extensions: SwiftProtobuf.SimpleExtensionMap = [
63+
Google_Api_Extensions_http
64+
]
65+
66+
/// See `HttpRule`.
67+
let Google_Api_Extensions_http = SwiftProtobuf.MessageExtension<SwiftProtobuf.OptionalMessageExtensionField<Google_Api_HttpRule>, SwiftProtobuf.Google_Protobuf_MethodOptions>(
68+
_protobuf_fieldNumber: 72295728,
69+
fieldName: "google.api.http"
70+
)

0 commit comments

Comments
 (0)