I have two Swift modules/pods: FirstPod and SecondPod. Both use C++ interop, and both call Swift classes/functions from C++.
FirstPod has this class:
open class First { … }
SecondPod has this class:
import FirstPod
public class Second: First { … }
Because Second inherits from First, the SecondPod-Swift.h header file produces build errors since it cannot find Second's base class (First) as that is nowhere included:
- Unknown class name 'First'
Code:
class SWIFT_SYMBOL("s:13Second06FirstC") Second : public FirstPod::First {
public:
using First::First;
using First::operator=;
static SWIFT_INLINE_THUNK Second init() SWIFT_SYMBOL("s:13Second06FirstCACycfc");
protected:
SWIFT_INLINE_THUNK Second(void * _Nonnull ptr) noexcept : First(ptr) {}
private:
friend class _impl::_impl_Second;
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wc++17-extensions"
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wreserved-identifier"
typedef char $s13Second06FirstCD;
static inline constexpr $s13Second06FirstCD __swift_mangled_name = 0;
#pragma clang diagnostic pop
#pragma clang diagnostic pop
};
- Forward-declaring doesn't help either, since it needs a concrete type for a base class.
- Including
FirstPod-Swift.hbefore I includeSecondPod-Swift.hdoesn't work either because (as far as I know) you cannot include the-Swift.hheader of another module inside your module.
I'm out of ideas at this point. Any suggestions?