grpc / grpc-swift

The Swift language implementation of gRPC.
Apache License 2.0
2.04k stars 420 forks source link

Compatibility with macOS 10.15 Catalina? #502

Closed cielo closed 4 years ago

cielo commented 5 years ago

Question Checklist

Question Subject

I am unable to generate swift grpc files due to an 'libswiftCore.dylib' error.

Question Description

Hello,

I installed the latest version of plugin grpc/grpc-swift today, and was trying to generate Swift & SwiftGRPC files based on .proto file I have.

When I run protoc command just with --swift_out & --swiftgrpc_out, I get the following error.

This copy of libswiftCore.dylib requires an OS version prior to 10.14.4.
--swiftgrpc_out: protoc-gen-swiftgrpc: Plugin killed by signal 6.

I am on macOS 10.15 Catalina Beta in order to develop using Xcode 11, and I have hit a roadblock because of this. If I wanted to check out versions... I get the similar error as well.

my-mbp:~/Dev/grpc-swift> protoc-gen-swift --version
This copy of libswiftCore.dylib requires an OS version prior to 10.14.4.
zsh: abort      protoc-gen-swift --version
my-mbp:~/Dev/grpc-swift> protoc-gen-swiftgrpc --version
This copy of libswiftCore.dylib requires an OS version prior to 10.14.4.
zsh: abort      protoc-gen-swiftgrpc --version
my-mbp:~/Dev/grpc-swift

The strange thing here is that, protoc-gen-swift binary generated from this repo does not work due to above error, but protoc-gen-swift binary installed from this repo's https://github.com/apple/swift-protobuf brew install works fine in my system. The latter protoc-gen-swift's version is 1.5.0 and it can generate swift files based on my proto file without an issue.

Is the latest version of grpc/grpc-swift not yet compatible with macOS 10.15?

MrMage commented 5 years ago

How did you build the protoc plugin for Swift GRPC? On which OS version did you build that plugin?

cielo commented 5 years ago

For protoc binary, I downloaded version 3.8.0 from https://github.com/protocolbuffers/protobuf/releases.

For this 'SwiftGRPC' plugin, I built it in macOS 10.15 Beta 2 Catalina by running make plugin command. While building the plugin, it did generate few warning logs..

my-mbp:~/Dev/grpc-swift>make clean
...
my-mbp:~/Dev/grpc-swift>make plugin
swift build -Xcc -ISources/BoringSSL/include -Xlinker -lz --product protoc-gen-swift --static-swift-stdlib -c release
Fetching https://github.com/apple/swift-protobuf.git
Fetching https://github.com/kylef/Commander.git
Fetching https://github.com/apple/swift-nio-nghttp2-support.git
Fetching https://github.com/apple/swift-nio-zlib-support.git
Fetching https://github.com/apple/swift-nio.git
Fetching https://github.com/apple/swift-nio-http2.git
Fetching https://github.com/kylef/Spectre.git
Completed resolution in 9.37s
Cloning https://github.com/apple/swift-nio-http2.git
Resolving https://github.com/apple/swift-nio-http2.git at 0.2.1
Cloning https://github.com/kylef/Spectre.git
Resolving https://github.com/kylef/Spectre.git at 0.9.0
Cloning https://github.com/kylef/Commander.git
Resolving https://github.com/kylef/Commander.git at 0.8.0
Cloning https://github.com/apple/swift-nio-nghttp2-support.git
Resolving https://github.com/apple/swift-nio-nghttp2-support.git at 1.0.0
Cloning https://github.com/apple/swift-nio-zlib-support.git
Resolving https://github.com/apple/swift-nio-zlib-support.git at 1.0.0
Cloning https://github.com/apple/swift-nio.git
Resolving https://github.com/apple/swift-nio.git at 1.14.1
Cloning https://github.com/apple/swift-protobuf.git
Resolving https://github.com/apple/swift-protobuf.git at 1.5.0
warning: you may be able to install libnghttp2 using your system-packager:
     brew install nghttp2

'swift-nio-zlib-support' zlib.pc: warning: couldn't find pc file
warning: Swift compiler no longer supports statically linking the Swift libraries. They're included in the OS by default starting with macOS Mojave 10.14.4. For macOS Mojave 10.14.3 and earlier, there's an optional Swift library package that can be downloaded from "More Downloads" for Apple Developers at https://developer.apple.com/download/more/
(...repeated many times)
warning: Swift compiler no longer supports statically linking the Swift libraries. They're included in the OS by default starting with macOS Mojave 10.14.4. For macOS Mojave 10.14.3 and earlier, there's an optional Swift library package that can be downloaded from "More Downloads" for Apple Developers at https://developer.apple.com/download/more/
[4/4] Linking ./.build/x86_64-apple-macosx/release/protoc-gen-swift
swift build -Xcc -ISources/BoringSSL/include -Xlinker -lz --product protoc-gen-swiftgrpc --static-swift-stdlib -c release
warning: you may be able to install libnghttp2 using your system-packager:
     brew install nghttp2

'swift-nio-zlib-support' zlib.pc: warning: couldn't find pc file
warning: Swift compiler no longer supports statically linking the Swift libraries. They're included in the OS by default starting with macOS Mojave 10.14.4. For macOS Mojave 10.14.3 and earlier, there's an optional Swift library package that can be downloaded from "More Downloads" for Apple Developers at https://developer.apple.com/download/more
(...repeated many times)
warning: Swift compiler no longer supports statically linking the Swift libraries. They're included in the OS by default starting with macOS Mojave 10.14.4. For macOS Mojave 10.14.3 and earlier, there's an optional Swift library package that can be downloaded from "More Downloads" for Apple Developers at https://developer.apple.com/download/more
[2/2] Linking ./.build/x86_64-apple-macosx/release/protoc-gen-swiftgrpc
cp .build/release/protoc-gen-swift .
cp .build/release/protoc-gen-swiftgrpc .
my-mbp:~/Dev/grpc-swift>
my-mbp:~/Dev/grpc-swift> ./protoc-gen-swift --version
This copy of libswiftCore.dylib requires an OS version prior to 10.14.4.
zsh: abort      ./protoc-gen-swift --version
my-mbp:~/Dev/grpc-swift> ./protoc-gen-swiftgrpc --version
This copy of libswiftCore.dylib requires an OS version prior to 10.14.4.
zsh: abort      ./protoc-gen-swiftgrpc --version
my-mbp:~/Dev/grpc-swift> 
MrMage commented 5 years ago

Thanks. Could you try removing the --static-swift-stdlib flags in the Makefile, run make plugin again, then see if that helps?

cielo commented 5 years ago

After removing the --static-swift-stdlib options from plugin target, if I run make clean; make plugin, build does not generate warnings related to statically linking the swift libraries anymore.

However, it still complains about libswiftCore.dylib.

:~/Dev/grpc-swift> make clean;make plugin;
rm -rf Packages
rm -rf .build build
rm -rf SwiftGRPC.xcodeproj
rm -rf Package.pins Package.resolved
rm -rf protoc-gen-swift protoc-gen-swiftgrpc
cd Examples/Google/Datastore && make clean
rm -rf Packages googleapis .build
rm -f Package.pins Datastore Sources/*.pb.swift Sources/*.grpc.swift google.json
rm -rf Package.resolved
cd Examples/Google/NaturalLanguage && make clean
rm -rf Packages googleapis .build
rm -f Package.pins NaturalLanguage Sources/*.pb.swift Sources/*.grpc.swift google.json
rm -rf Package.resolved
cd Examples/Google/Spanner && make clean
rm -rf Packages googleapis .build
rm -f Package.pins Spanner Sources/*.pb.swift Sources/*.grpc.swift google.json
rm -rf Package.resolved
swift build -Xcc -ISources/BoringSSL/include -Xlinker -lz --product protoc-gen-swift -c release
Fetching https://github.com/apple/swift-protobuf.git
Fetching https://github.com/kylef/Commander.git
Fetching https://github.com/apple/swift-nio-zlib-support.git
Fetching https://github.com/apple/swift-nio.git
Fetching https://github.com/apple/swift-nio-nghttp2-support.git
Fetching https://github.com/apple/swift-nio-http2.git
Fetching https://github.com/kylef/Spectre.git
Completed resolution in 8.74s
Cloning https://github.com/apple/swift-nio-nghttp2-support.git
Resolving https://github.com/apple/swift-nio-nghttp2-support.git at 1.0.0
Cloning https://github.com/kylef/Commander.git
Resolving https://github.com/kylef/Commander.git at 0.8.0
Cloning https://github.com/apple/swift-nio.git
Resolving https://github.com/apple/swift-nio.git at 1.14.1
Cloning https://github.com/apple/swift-protobuf.git
Resolving https://github.com/apple/swift-protobuf.git at 1.5.0
Cloning https://github.com/apple/swift-nio-http2.git
Resolving https://github.com/apple/swift-nio-http2.git at 0.2.1
Cloning https://github.com/kylef/Spectre.git
Resolving https://github.com/kylef/Spectre.git at 0.9.0
Cloning https://github.com/apple/swift-nio-zlib-support.git
Resolving https://github.com/apple/swift-nio-zlib-support.git at 1.0.0
'swift-nio-zlib-support' zlib.pc: warning: couldn't find pc file
warning: you may be able to install libnghttp2 using your system-packager:
     brew install nghttp2

[4/4] Linking ./.build/x86_64-apple-macosx/release/protoc-gen-swift
swift build -Xcc -ISources/BoringSSL/include -Xlinker -lz --product protoc-gen-swiftgrpc -c release
'swift-nio-zlib-support' zlib.pc: warning: couldn't find pc file
warning: you may be able to install libnghttp2 using your system-packager:
     brew install nghttp2

[2/2] Linking ./.build/x86_64-apple-macosx/release/protoc-gen-swiftgrpc
cp .build/release/protoc-gen-swift .
cp .build/release/protoc-gen-swiftgrpc .
:~/Dev/grpc-swift> ./protoc-gen-swift --version
This copy of libswiftCore.dylib requires an OS version prior to 10.14.4.
zsh: abort      ./protoc-gen-swift --version
:~/Dev/grpc-swift> ./protoc-gen-swiftgrpc --version
This copy of libswiftCore.dylib requires an OS version prior to 10.14.4.
zsh: abort      ./protoc-gen-swiftgrpc --version
:~/Dev/grpc-swift> 

Does this plugin change anything about apple/swift-protobuf.git's ./protoc-gen-swift? Apple one seems to work fine in my setup, but unfortunately, it does not contain gRPC specific service code gen so I have to rely on this repo.

bohachevskyy commented 5 years ago

Hey @cielo I'm facing the same issue. Did you manage to solve it?

aostiles commented 5 years ago

I had this issue and got them to work using the swift 5.1 command line tool. This post was key for me. I haven't actually tried building an iOS app yet, but compiling a proto file with protoc <my_proto_file> --swift_out=. --swiftgrpc_out=Client=true,Server=false:. seems to work. I'm using libprotoc 3.9.0, built protoc-gen-swift and protoc-gen-swiftgrpc from this repo (8eac348), and am running the Catalina beta (19A526h). swift reports (swiftlang-1100.0.266.1 clang-1100.0.32.1).