grpc-swift: Swift Package Manager 5.1.0 missing SwiftGRPC on Import

New Issue Checklist

Issue Description

Starting with an Swift UI application in Xcode

  1. Single View App
  2. Enter Required Info
  3. Unchecked Include Unit Tests / Include UI Tests
  4. Went to add package dependency
  5. Used the following url https://github.com/grpc/grpc-swift
  6. Selected Branch and typed in nio
  7. Confirmed that under Package Product the only fields were GRPC | Library | Name Of Project
  8. Clicked Finish
  9. Went to SceneDelegate.swift then proceeded to type in import SwiftGRPC
  10. Resulting error of No such module SwiftGRPC
  11. Types in GRPC instead via this route and has no issues
  12. Import the .grpc and .pb.swift files as mentioned here, medium starter
  13. As a result inside of the files the following message is shown in step 10.

Unsure of how to proceed based upon the documentation in the readMe, also looking into the following Stack Overflow thread this solution did not appear to work either. Any help would be appreciated.

alt text

Thanks

Complete output when running grpc-swift, including the stack trace and command used
No such module `SwiftGRPC`

Environment

Key Value
OS Version 10.15.3
Swift Version 5.1.3
Xcode Version 11.3.1
gRPC-Swift Version 1.0.0-alpha.9
gRPC-Swift Version 1.0.0-alpha.9
protoc Version 3.11.3
protoc-gen-swift Version 1.5.0
protoc-gen-swiftgrpc Version ?.?.?

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 16 (2 by maintainers)

Most upvoted comments

Got it! This is now working thank you! I had installed grpc-swift from Homebrew which appears to have not had the protoc-gen-grpc-swift binary in it.

@trujamal sorry for the slow response here; I’ve been away.

  1. Import the .grpc and .pb.swift files as mentioned here, medium starter

The tutorial linked is for the old version of (aka SwiftGRPC); the missing files you’re seeing here are for that version of gRPC Swift. I.e. you’re using generated code for the old version with the runtime for the new version (GRPC).

The instructions for generating the code from that article broadly apply to the new version as well. However they are not specific enough:

Once you have the .proto file, we need a SwiftGRPC plugin to convert the .proto files into .swift and .pb.swift files. In order to do that, we need to clone the SwiftGRPC open source project.

This is correct but you must also checkout the version of gRPC Swift that is resolved in Package.resolved (or Package.swift if you depend on an exact version).

TLDR: Fork the repository, and replace the Package.swift contents with the contents above and set the package dependency url to your fork.

This isn’t necessary unless you want to build the old version with Xcode via Swift Package Manager.