diff --git a/README.md b/README.md index 8c11a1979..717f7ac4c 100644 --- a/README.md +++ b/README.md @@ -102,6 +102,9 @@ the following line to your `Podfile`: Then, run `pod install` from command line and use your project's generated `.xcworkspace` file. You might also need to add `use_frameworks!` to your `Podfile`. +*⚠️ If you have conficting modules as a result of having a transitive +dependency on '[gRPC-Core][grpc-core-pod]' see [grpc/grpc-swift#945][grpc-swift-945].* + ### Getting the `protoc` Plugins Binary releases of `protoc`, the Protocol Buffer Compiler, are available on @@ -171,6 +174,8 @@ Please get involved! See our [guidelines for contributing](CONTRIBUTING.md). [docs-keepalive]: ./docs/keepalive.md [docs-tutorial]: ./docs/basic-tutorial.md [grpc]: https://github.com/grpc/grpc +[grpc-core-pod]: https://cocoapods.org/pods/gRPC-Core +[grpc-swift-945]: https://github.com/grpc/grpc-swift/pull/945 [protobuf-releases]: https://github.com/protocolbuffers/protobuf/releases [swift-nio-platforms]: https://github.com/apple/swift-nio#supported-platforms [swift-nio]: https://github.com/apple/swift-nio diff --git a/Sources/Examples/Echo/Model/echo.grpc.swift b/Sources/Examples/Echo/Model/echo.grpc.swift index 2f26a39e5..b839b28ef 100644 --- a/Sources/Examples/Echo/Model/echo.grpc.swift +++ b/Sources/Examples/Echo/Model/echo.grpc.swift @@ -20,11 +20,8 @@ // See the License for the specific language governing permissions and // limitations under the License. // -import Foundation import GRPC import NIO -import NIOHTTP1 -import SwiftProtobuf /// Usage: instantiate Echo_EchoClient, then call methods of this protocol to make API calls. diff --git a/Sources/Examples/HelloWorld/Model/helloworld.grpc.swift b/Sources/Examples/HelloWorld/Model/helloworld.grpc.swift index 8783c7803..3ca06cfb0 100644 --- a/Sources/Examples/HelloWorld/Model/helloworld.grpc.swift +++ b/Sources/Examples/HelloWorld/Model/helloworld.grpc.swift @@ -20,11 +20,8 @@ // See the License for the specific language governing permissions and // limitations under the License. // -import Foundation import GRPC import NIO -import NIOHTTP1 -import SwiftProtobuf /// Usage: instantiate Helloworld_GreeterClient, then call methods of this protocol to make API calls. diff --git a/Sources/Examples/RouteGuide/Model/route_guide.grpc.swift b/Sources/Examples/RouteGuide/Model/route_guide.grpc.swift index 789326e82..410588b22 100644 --- a/Sources/Examples/RouteGuide/Model/route_guide.grpc.swift +++ b/Sources/Examples/RouteGuide/Model/route_guide.grpc.swift @@ -20,11 +20,8 @@ // See the License for the specific language governing permissions and // limitations under the License. // -import Foundation import GRPC import NIO -import NIOHTTP1 -import SwiftProtobuf /// Usage: instantiate Routeguide_RouteGuideClient, then call methods of this protocol to make API calls. diff --git a/Sources/GRPCInteroperabilityTestModels/Generated/test.grpc.swift b/Sources/GRPCInteroperabilityTestModels/Generated/test.grpc.swift index 1aab97fcb..9dff96b11 100644 --- a/Sources/GRPCInteroperabilityTestModels/Generated/test.grpc.swift +++ b/Sources/GRPCInteroperabilityTestModels/Generated/test.grpc.swift @@ -20,11 +20,8 @@ // See the License for the specific language governing permissions and // limitations under the License. // -import Foundation import GRPC import NIO -import NIOHTTP1 -import SwiftProtobuf /// Usage: instantiate Grpc_Testing_TestServiceClient, then call methods of this protocol to make API calls. diff --git a/Sources/protoc-gen-grpc-swift/Generator.swift b/Sources/protoc-gen-grpc-swift/Generator.swift index ac4d41f85..5d3cf5b33 100644 --- a/Sources/protoc-gen-grpc-swift/Generator.swift +++ b/Sources/protoc-gen-grpc-swift/Generator.swift @@ -88,11 +88,8 @@ class Generator { """) let moduleNames = [ - "Foundation", + self.options.gRPCModuleName, "NIO", - "NIOHTTP1", - "GRPC", - "SwiftProtobuf", ] for moduleName in (moduleNames + self.options.extraModuleImports).sorted() { diff --git a/Sources/protoc-gen-grpc-swift/options.swift b/Sources/protoc-gen-grpc-swift/options.swift index 4094e96de..cd3c95585 100644 --- a/Sources/protoc-gen-grpc-swift/options.swift +++ b/Sources/protoc-gen-grpc-swift/options.swift @@ -58,6 +58,7 @@ final class GeneratorOptions { private(set) var protoToModuleMappings = ProtoFileToModuleMappings() private(set) var fileNaming = FileNaming.FullPath private(set) var extraModuleImports: [String] = [] + private(set) var gRPCModuleName = "GRPC" init(parameter: String?) throws { for pair in GeneratorOptions.parseParameter(string: parameter) { @@ -116,6 +117,13 @@ final class GeneratorOptions { throw GenerationError.invalidParameterValue(name: pair.key, value: pair.value) } + case "GRPCModuleName": + if !pair.value.isEmpty { + self.gRPCModuleName = pair.value + } else { + throw GenerationError.invalidParameterValue(name: pair.key, value: pair.value) + } + default: throw GenerationError.unknownParameter(name: pair.key) } diff --git a/dev/codegen-tests/01-echo/golden/echo.grpc.swift b/dev/codegen-tests/01-echo/golden/echo.grpc.swift index 4df7ef463..fb41201c0 100644 --- a/dev/codegen-tests/01-echo/golden/echo.grpc.swift +++ b/dev/codegen-tests/01-echo/golden/echo.grpc.swift @@ -20,11 +20,8 @@ // See the License for the specific language governing permissions and // limitations under the License. // -import Foundation import GRPC import NIO -import NIOHTTP1 -import SwiftProtobuf /// Usage: instantiate Echo_EchoClient, then call methods of this protocol to make API calls. diff --git a/dev/codegen-tests/02-multifile/golden/a.grpc.swift b/dev/codegen-tests/02-multifile/golden/a.grpc.swift index 6afe20676..f4d7cc2f3 100644 --- a/dev/codegen-tests/02-multifile/golden/a.grpc.swift +++ b/dev/codegen-tests/02-multifile/golden/a.grpc.swift @@ -20,11 +20,8 @@ // See the License for the specific language governing permissions and // limitations under the License. // -import Foundation import GRPC import NIO -import NIOHTTP1 -import SwiftProtobuf /// Usage: instantiate A_ServiceAClient, then call methods of this protocol to make API calls. diff --git a/dev/codegen-tests/02-multifile/golden/b.grpc.swift b/dev/codegen-tests/02-multifile/golden/b.grpc.swift index 8f9778cd7..1c64beb9e 100644 --- a/dev/codegen-tests/02-multifile/golden/b.grpc.swift +++ b/dev/codegen-tests/02-multifile/golden/b.grpc.swift @@ -20,11 +20,8 @@ // See the License for the specific language governing permissions and // limitations under the License. // -import Foundation import GRPC import NIO -import NIOHTTP1 -import SwiftProtobuf /// Usage: instantiate B_ServiceBClient, then call methods of this protocol to make API calls. diff --git a/dev/codegen-tests/03-multifile-with-module-map/golden/a.grpc.swift b/dev/codegen-tests/03-multifile-with-module-map/golden/a.grpc.swift index b53e27ba9..ba430d2e9 100644 --- a/dev/codegen-tests/03-multifile-with-module-map/golden/a.grpc.swift +++ b/dev/codegen-tests/03-multifile-with-module-map/golden/a.grpc.swift @@ -20,11 +20,8 @@ // See the License for the specific language governing permissions and // limitations under the License. // -import Foundation import GRPC import NIO -import NIOHTTP1 -import SwiftProtobuf import ModuleB diff --git a/dev/codegen-tests/03-multifile-with-module-map/golden/b.grpc.swift b/dev/codegen-tests/03-multifile-with-module-map/golden/b.grpc.swift index 8f9778cd7..1c64beb9e 100644 --- a/dev/codegen-tests/03-multifile-with-module-map/golden/b.grpc.swift +++ b/dev/codegen-tests/03-multifile-with-module-map/golden/b.grpc.swift @@ -20,11 +20,8 @@ // See the License for the specific language governing permissions and // limitations under the License. // -import Foundation import GRPC import NIO -import NIOHTTP1 -import SwiftProtobuf /// Usage: instantiate B_ServiceBClient, then call methods of this protocol to make API calls. diff --git a/dev/codegen-tests/04-service-with-message-import/golden/service.grpc.swift b/dev/codegen-tests/04-service-with-message-import/golden/service.grpc.swift index 131c6dfa9..04e1d1e6f 100644 --- a/dev/codegen-tests/04-service-with-message-import/golden/service.grpc.swift +++ b/dev/codegen-tests/04-service-with-message-import/golden/service.grpc.swift @@ -20,11 +20,8 @@ // See the License for the specific language governing permissions and // limitations under the License. // -import Foundation import GRPC import NIO -import NIOHTTP1 -import SwiftProtobuf /// Usage: instantiate Codegentest_FooClient, then call methods of this protocol to make API calls. diff --git a/dev/codegen-tests/05-service-only/golden/test.grpc.swift b/dev/codegen-tests/05-service-only/golden/test.grpc.swift index 702f3de03..31edb4628 100644 --- a/dev/codegen-tests/05-service-only/golden/test.grpc.swift +++ b/dev/codegen-tests/05-service-only/golden/test.grpc.swift @@ -20,11 +20,8 @@ // See the License for the specific language governing permissions and // limitations under the License. // -import Foundation import GRPC import NIO -import NIOHTTP1 -import SwiftProtobuf /// Usage: instantiate Codegentest_FooClient, then call methods of this protocol to make API calls. diff --git a/dev/codegen-tests/06-test-client-only/golden/test.grpc.swift b/dev/codegen-tests/06-test-client-only/golden/test.grpc.swift index f8bcca0a3..f7af8fe23 100644 --- a/dev/codegen-tests/06-test-client-only/golden/test.grpc.swift +++ b/dev/codegen-tests/06-test-client-only/golden/test.grpc.swift @@ -20,11 +20,8 @@ // See the License for the specific language governing permissions and // limitations under the License. // -import Foundation import GRPC import NIO -import NIOHTTP1 -import SwiftProtobuf internal final class Codegentest_FooTestClient: Codegentest_FooClientProtocol { diff --git a/docs/plugin.md b/docs/plugin.md index 068dd754e..46c0f8246 100644 --- a/docs/plugin.md +++ b/docs/plugin.md @@ -74,6 +74,15 @@ The **FileNaming** option determines how generated source files should be named. The **ProtoPathModuleMappings** option allows module mappings to be specified. See the [SwiftProtobuf documentation][swift-protobuf-module-mappings]. +### GRPCModuleName + +The **GRPCModuleName** option allows the name of the gRPC Swift runtime module +to be specified. The value, if not specified, defaults to "GRPC". + +*Note: most users will not need to use this option. It is intended as a +workaround for CocoaPods users who may end up with a transitive dependency on +the gRPC core C library whose module name is also "GRPC".* + ## Specifying Options To pass extra parameters to the plugin, use a comma-separated parameter list