Reputation: 10788
I'm trying to build a library to distribute via Cocoapods. The library is written mainly in Objective C, but includes a few C++ files. None of the C++ headers are part of the library's public API. The library builds fine in Xcode, and I can distribute as a framework, but a pod is probably easier for others to consume, right?
This is my first time attempting to build a cocoapod, so I may be doing something obviously wrong.
When I run pod lib lint
or try to build the demo app that depends on the pod, I get error messages that suggest that the build system doesn't understand C++ at all.
in a C++ header file:
class CGuard {
> unknown type name 'class'; did you mean 'Class'?
in another C++ header file:
template<typename T>
class CContexts {
> unknown type name 'template'
My podspec file includes
spec.xcconfig = {
'CLANG_CXX_LANGUAGE_STANDARD' => 'c++11',
'CLANG_CXX_LIBRARY' => 'libc++'
}
spec.library = "c++"
What else can I do to tell the build system to use the C++ compiler?
Upvotes: 3
Views: 1040
Reputation: 10788
It looks like the key was adding private_header_files
entries to remove the C++ headers from the framework that Cocoapods exports.
Although Cocoapods is documented to only include the files from public_header_files
in the generated module umbrella header, it looks like each subspec
section has all of its headers included if that subspec
section doesn't have its own public_header_files
entry.
The C++ files were all compiled in a subspec
section to let me use different compiler settings, so the private_header_files
entry needed to be inside that subspec
section as well.
Upvotes: 1