"Use of undeclared identifier 'Darwin'" when using "in_addr" type

When using "in_addr" in Swift, enabling C++ interoperability, and importing the generated Swift.h header into a C++ file, this error gets produced from the Swift.h file.

Swift:

import Darwin

public enum MyEnum {
    case value(in_addr)
}

C++

#include <netinet/in.h>
#include "MyProject-Swift.h"

The generated code is using Darwin as a namespace but I'm unable to to resolve this error. This is from Xcode 16.1. Any suggestions?

Still can repro on Xcode 16.2. I’ve tried playing with enabling C++ modules, different C++ versions, manually importing Darwin framework, using ObjC++. Nothing helps.

Should I file a bug on GitHub? Apple Feedback?

I did some experimentation and found if I replaced in_addr with pthread_t the generated header produces an error about the type can’t be represented in Swift, so possibly a clue. I also found in the SDK folder some Darwin module map files with in_addr references that may hold more clues. Of course it’s in Xcode.app so it can’t be modified. Lastly, I found a workaround by moving the classes into a separate library that doesn’t need to have any sources imported from a generated Swift header. Basically an all-Swift library, whereas they were previously in a mixed language library.