KSCrash
KSCrash copied to clipboard
Issue co-existing with gRPC library (Swift, CocoaPods)
Hello,
We have found that when the KSCrash pod is included with the gRPC-Core pod, it leads to C++ 'undefined template' errors to do with the Optional type.
The minimal reproduction case is to:
- Create an empty iOS application using Swift in Xcode
- Run
pod init
- Add
pod 'KSCrash'
andpod 'gRPC-Core'
to the dependencies - Run
pod install
- Open the workspace file
- Try to build the project
Compilation is halted early due to many errors such as:
Implicit instantiation of undefined template 'llvm::Optional
' Demangle.cpp
As I understand it, both dependencies declare an Optional template, but in different namespaces. Independently these dependencies compile fine, but together you can observe the errors above.
Can anyone possibly explain the issue and point us in the right direction for a solution to enable use of both libraries?
Thanks in advance, Chris
P.S. this is the tooling I'm using:
- Xcode 10.2.1
- Swift 5
- CocoaPods 1.7.1
@cgwyllie , do you try use Firestore in the same project? I'm experiencing this compilation error as well, only when I try to use Firestore at the same time, so it seems like a conflict (see this comment: https://github.com/rollbar/rollbar-ios/issues/244#issuecomment-580779316).
Did you solve it somehow? I'm thinking about two solutions:
- Pre-compile KSCrash to a framework and use it directly from my library (I still don't know how to do it because I created a CocoaPod that uses KSCrash).
- Solve it in an elegant way with my
podspec
configuration (still don't know how).
Hi @PerrchicK, we traced it ultimately back to the gRPC library (as noted in this issue), which is a dependency of Firestore (how we initially discovered it).
We're not sure on the best resolution as yet but it does seem some others are encountering similar/related issues.
After reading around this issue based on work by Rollbar, and similar issues from Facebook's react-native, it seems this can be resolved by disabling header maps, and linking against llvm when building in CocoaPods.
For example, in the Podspec, adding:
s.ios.libraries = 'c++', 'z', 'llvm'
s.ios.pod_target_xcconfig = {
'USE_HEADERMAP' => 'NO',
'HEADER_SEARCH_PATHS' => '"$(PODS_ROOT)/KSCrash/**"'
}
This is based on:
- https://github.com/rollbar/rollbar-ios/pull/275
- https://github.com/facebook/react-native/commit/f3f44eee59e8991e197c854e5fee719105c045cd
Header maps seem to flatten includes based on name across many libraries, which results in the wrong headers being used in the wrong projects. See https://developer.apple.com/library/archive/documentation/DeveloperTools/Reference/XcodeBuildSettingRef/1-Build_Setting_Reference/build_setting_ref.html "Header-Map Build Settings" for context.
Not sure if this is a suitable long-term solution, but if so would happily produce a PR to that effect.