Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cocoapods Support? #111

Closed
AttilaTheFun opened this issue Feb 8, 2018 · 19 comments · Fixed by #207
Closed

Cocoapods Support? #111

AttilaTheFun opened this issue Feb 8, 2018 · 19 comments · Fixed by #207

Comments

@AttilaTheFun
Copy link

I'm interested in using this library for a prototype Swift iOS application. It's nice that https://github.com/apple/swift-protobuf allows for installation. I was wondering if it would be possible to offer the SwiftGRPC.xcodeproj through Cocoapods, though I suppose it would require BoringSSL, CgRPC, gRPC, and CzLib all be available through Cocoapods as well.

@muxi
Copy link
Member

muxi commented Feb 8, 2018

We have that in the list.

gRPC and BoringSSL are in Cocoapods already.

@AttilaTheFun
Copy link
Author

@muxi why does the podspec say it’s incomplete?

@timburks
Copy link
Member

@AttilaTheFun I started the podspec and ran into problems, so I renamed it to avoid over-promising (since it didn't work). I'm not a Cocoapods user, so am hoping @muxi can help from his experience with Objective-C gRPC.

@AttilaTheFun
Copy link
Author

@muxi @timburks I tried forking the library and linting the podspec. I got an error about a double-import from the boringSSL module map. I googled around about the error and I think it has since been fixed, but the version of gRPC-Core depended on by this library is significantly out of date. (1.0.1 vs 1.9.1 which is current). When I tried to bump the gRPC-Core version to 1.9.1, I got a bunch of compile errors because I think this library used some non-backwards compatible APIs. Is it possible to get grpc-swift to be compatible with the latest version of grpc-core?

@AttilaTheFun
Copy link
Author

Btw here is the discussion about the issue I see currently:
GoogleCloudPlatform/ios-docs-samples#39

@MrMage
Copy link
Collaborator

MrMage commented Feb 19, 2018

I have created a Podspec depending on the latest gRPC version (1.9.1) that seems to compile for my project. You should be able to try it out via the following pod includes:

pod 'BoringSSL', '~> 9.1'
pod 'gRPC-Core', :git => 'https://github.com/mrmage/grpc', :branch => 'fix-cocoapods-swift'
pod 'SwiftGRPC', :git => 'https://github.com/mrmage/grpc-swift', :branch => 'podspec'

Not sure if this is production ready yet (I might have missed something and it generates a lot of warnings because shim/cgrpc.h isn't very pretty), but I would appreciate if you could try it out and give feedback, so I can send a pull request sometime soon.

Note that generated code currently refers to the gRPC package, while the CocoaPod generates a SwiftGRPC package. Not sure about the best way to solve that, as CocoaPods projects also include the grpc package (from gRPC-Core), and I think having both grpc and gRPC packages in the same project would be confusing.

For now, I'm solving this by running

sed -i'.bak' 's/gRPC/SwiftGRPC/' Proto/*.swift
rm Proto/*.bak

after running the codegen (assuming the generated code is in the Proto directory).

@MrMage MrMage mentioned this issue Feb 19, 2018
@AttilaTheFun
Copy link
Author

@MrMage I tried adding your branches as dependencies in my pod file but was unable to install them because I don't believe they're published to the master specs repo. I then attempted to clone your forks and push your pod specs to my private repo, and the gRPC-Core spec didn't validate. This was the output of the failed validation:

Validating spec
 -> gRPC-Core (1.9.1)
    - ERROR | [gRPC-Core/Implementation, gRPC-Core/Cronet-Implementation, gRPC-Core/Tests, and more...] xcodebuild: Returned an unsuccessful exit code. You can use `--verbose` for more information.
    - ERROR | xcodebuild:  /var/folders/9j/zzwbsh056dx9ddrwb3b_jbrh0000gn/T/CocoaPods-Lint-20180220-13301-1jmikt0-gRPC-Core/DerivedData/App/Build/Products/Release-iphonesimulator/gRPC-Core/grpc.framework/Headers/support/log.h:22:10: error: include of non-modular header inside framework module 'grpc': '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/9.0.0/include/inttypes.h' [-Werror,-Wnon-modular-include-in-framework-module]
    - WARN  | xcodebuild:  /var/folders/9j/zzwbsh056dx9ddrwb3b_jbrh0000gn/T/CocoaPods-Lint-20180220-13301-1jmikt0-gRPC-Core/DerivedData/App/Build/Products/Release-iphonesimulator/gRPC-Core/grpc.framework/Headers/support/subprocess.h:31:51: warning: this function declaration is not a prototype [-Wstrict-prototypes]
    - WARN  | xcodebuild:  /var/folders/9j/zzwbsh056dx9ddrwb3b_jbrh0000gn/T/CocoaPods-Lint-20180220-13301-1jmikt0-gRPC-Core/DerivedData/App/Build/Products/Release-iphonesimulator/gRPC-Core/grpc.framework/Headers/impl/codegen/fork.h:40:18: warning: this function declaration is not a prototype [-Wstrict-prototypes]
    - WARN  | xcodebuild:  /var/folders/9j/zzwbsh056dx9ddrwb3b_jbrh0000gn/T/CocoaPods-Lint-20180220-13301-1jmikt0-gRPC-Core/DerivedData/App/Build/Products/Release-iphonesimulator/gRPC-Core/grpc.framework/Headers/impl/codegen/fork.h:42:26: warning: this function declaration is not a prototype [-Wstrict-prototypes]
    - WARN  | xcodebuild:  /var/folders/9j/zzwbsh056dx9ddrwb3b_jbrh0000gn/T/CocoaPods-Lint-20180220-13301-1jmikt0-gRPC-Core/DerivedData/App/Build/Products/Release-iphonesimulator/gRPC-Core/grpc.framework/Headers/impl/codegen/fork.h:44:25: warning: this function declaration is not a prototype [-Wstrict-prototypes]
    - WARN  | xcodebuild:  /var/folders/9j/zzwbsh056dx9ddrwb3b_jbrh0000gn/T/CocoaPods-Lint-20180220-13301-1jmikt0-gRPC-Core/DerivedData/App/Build/Products/Release-iphonesimulator/gRPC-Core/grpc.framework/Headers/impl/codegen/fork.h:46:38: warning: this function declaration is not a prototype [-Wstrict-prototypes]
    - NOTE  | [gRPC-Core/Implementation,gRPC-Core/Tests] xcodebuild:  /var/folders/9j/zzwbsh056dx9ddrwb3b_jbrh0000gn/T/CocoaPods-Lint-20180220-13301-1jmikt0-gRPC-Core/App/main.m:3:9: fatal error: could not build module 'grpc'
    - ERROR | [OSX] xcodebuild:  /var/folders/9j/zzwbsh056dx9ddrwb3b_jbrh0000gn/T/CocoaPods-Lint-20180220-13301-1jmikt0-gRPC-Core/DerivedData/App/Build/Products/Release/gRPC-Core/grpc.framework/Headers/support/log.h:22:10: error: include of non-modular header inside framework module 'grpc': '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/9.0.0/include/inttypes.h' [-Werror,-Wnon-modular-include-in-framework-module]
    - WARN  | [OSX] xcodebuild:  /var/folders/9j/zzwbsh056dx9ddrwb3b_jbrh0000gn/T/CocoaPods-Lint-20180220-13301-1jmikt0-gRPC-Core/DerivedData/App/Build/Products/Release/gRPC-Core/grpc.framework/Headers/support/subprocess.h:31:51: warning: this function declaration is not a prototype [-Wstrict-prototypes]
    - WARN  | [OSX] xcodebuild:  /var/folders/9j/zzwbsh056dx9ddrwb3b_jbrh0000gn/T/CocoaPods-Lint-20180220-13301-1jmikt0-gRPC-Core/DerivedData/App/Build/Products/Release/gRPC-Core/grpc.framework/Headers/impl/codegen/fork.h:40:18: warning: this function declaration is not a prototype [-Wstrict-prototypes]
    - WARN  | [OSX] xcodebuild:  /var/folders/9j/zzwbsh056dx9ddrwb3b_jbrh0000gn/T/CocoaPods-Lint-20180220-13301-1jmikt0-gRPC-Core/DerivedData/App/Build/Products/Release/gRPC-Core/grpc.framework/Headers/impl/codegen/fork.h:42:26: warning: this function declaration is not a prototype [-Wstrict-prototypes]
    - WARN  | [OSX] xcodebuild:  /var/folders/9j/zzwbsh056dx9ddrwb3b_jbrh0000gn/T/CocoaPods-Lint-20180220-13301-1jmikt0-gRPC-Core/DerivedData/App/Build/Products/Release/gRPC-Core/grpc.framework/Headers/impl/codegen/fork.h:44:25: warning: this function declaration is not a prototype [-Wstrict-prototypes]
    - WARN  | [OSX] xcodebuild:  /var/folders/9j/zzwbsh056dx9ddrwb3b_jbrh0000gn/T/CocoaPods-Lint-20180220-13301-1jmikt0-gRPC-Core/DerivedData/App/Build/Products/Release/gRPC-Core/grpc.framework/Headers/impl/codegen/fork.h:46:38: warning: this function declaration is not a prototype [-Wstrict-prototypes]
    - ERROR | [gRPC-Core/Implementation,gRPC-Core/Tests] xcodebuild:  /var/folders/9j/zzwbsh056dx9ddrwb3b_jbrh0000gn/T/CocoaPods-Lint-20180220-13301-1jmikt0-gRPC-Core/DerivedData/App/Build/Products/Release-iphonesimulator/gRPC-Core/grpc.framework/Modules/module.modulemap:3:19: error: umbrella header 'grpc.h' not found
    - ERROR | [gRPC-Core/Implementation,gRPC-Core/Tests] xcodebuild:  /var/folders/9j/zzwbsh056dx9ddrwb3b_jbrh0000gn/T/CocoaPods-Lint-20180220-13301-1jmikt0-gRPC-Core/DerivedData/App/Build/Products/Release/gRPC-Core/grpc.framework/Modules/module.modulemap:3:19: error: umbrella header 'grpc.h' not found
    - NOTE  | [gRPC-Core/Cronet-Implementation] xcodebuild:  clang: error: linker command failed with exit code 1 (use -v to see invocation)
    - WARN  | [gRPC-Core/Tests] xcodebuild:  gRPC-Core/test/core/end2end/tests/streaming_error_response.cc:239:14: warning: variable 'status' may be uninitialized when used here [-Wconditional-uninitialized]
    - NOTE  | [gRPC-Core/Tests] xcodebuild:  gRPC-Core/test/core/end2end/tests/streaming_error_response.cc:114:3: note: variable 'status' is declared he

@MrMage
Copy link
Collaborator

MrMage commented Feb 20, 2018

@AttilaTheFun Sorry, the pod command for SwiftGRPC was wrong. It should have been this:

pod 'BoringSSL', '~> 9.1'
pod 'gRPC-Core', :git => 'https://github.com/mrmage/grpc', :branch => 'fix-cocoapods-swift'
pod 'SwiftGRPC', :git => 'https://github.com/mrmage/grpc-swift', :branch => 'podspec'

Could you try using those pod commands? They specifically should work without the master specs repo, because they point to my forks directly.

Also, what happens if you just try using them, regardless of what the linter says? I did not touch the gRPC Podspec at all (my only change in that repo is MrMage/grpc@21897a6), yet it works for me.

@AttilaTheFun
Copy link
Author

Hey @MrMage - getting closer! This time I was able to successfully pod install, but I got a build error for grpc:
screen shot 2018-02-20 at 12 28 51 pm
I think it may be because you deleted that header include.

@MrMage
Copy link
Collaborator

MrMage commented Feb 20, 2018

Could you just try the official gRPC-Core pod then?

@MrMage
Copy link
Collaborator

MrMage commented Feb 20, 2018

Also, not sure why not including inttypes.h should make memcpy unavailable.

@AttilaTheFun
Copy link
Author

@MrMage I tried the official pod and still got the same error. After some googling I found out I could fix it by replacing import "string.h" with import <string.h> Do you wanna make a PR to the gRPC library with that fix plus yours, or should I make that PR separately.

@MrMage
Copy link
Collaborator

MrMage commented Feb 21, 2018

Feel free to send a PR over to the gRPC team already :-) Note, though, that that patch might go into the v1.10-dev branch, which isn't yet working with my CocoaPod (or the SwiftGRPC library itself, I've forgotten).

@ghost
Copy link

ghost commented Mar 7, 2018

@MrMage, is this expected to be working at this time?

pod install is working great with just this line: pod 'SwiftGRPC', :git => 'https://github.com/grpc/grpc-swift'

However, compiling fails with this error:

<unknown>:0: error: filename "main.swift" used twice: '.../Pods/SwiftGRPC/Sources/RootsEncoder/main.swift' and '.../Pods/SwiftGRPC/Sources/protoc-gen-swiftgrpc/main.swift'
<unknown>:0: note: filenames are used to distinguish private declarations with the same name

Am I missing any steps?

@ghost
Copy link

ghost commented Mar 7, 2018

This issue blames to aa746f8.

Going beyond that though, looks like the inttypes.h include is still an issue. Removing that line like in your repo fixes it.

For anybody else, this should work:

pod 'gRPC-Core', :git => 'https://github.com/mrmage/grpc', :branch => 'fix-cocoapods-swift'
pod 'SwiftGRPC', :git => 'https://github.com/grpc/grpc-swift', :commit => 'b73abfe491759dd3e8e61e2a3d57defb8d720568'

@MrMage
Copy link
Collaborator

MrMage commented Mar 8, 2018

Thanks for figuring this out. We are still moving a lot of things around, but once the dust has settled I plan to fix the podspec. I have just filed grpc/grpc#14640 to get the inttypes.h fix merged upstream.

@MrMage
Copy link
Collaborator

MrMage commented Mar 8, 2018

@dhavalcue FYI, I updated the Podspec: #180

@bootstraponline
Copy link
Contributor

I added the pod:

pod 'SwiftGRPC', git: '[email protected]:grpc/grpc-swift.git'

There are compile errors:

image

Is the inttypes.h issue going to be fixed upstream?

@bootstraponline
Copy link
Contributor

  s.dependency 'gRPC-Core', '~> 1.11.0-pre2'
  s.dependency 'BoringSSL', '~> 10.0'
  s.dependency 'SwiftProtobuf', '~> 1.0.3'

I updated SwiftGRPC.podspec and that fixed the error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants