Is it possible to use @import in a header file?

I've created a package with the following structure:

Models - Swift
UseObjc - Objc, depends on Models
UseSwift - Swift, depends on UseObjc

The idea is to use an enum from Models as a property of an Objective C class. Therefore, in "UseObjc.h" I do @import Models.

Building Models or UseObjc succeeds. But UseSwift fails with two errors:

Sources/UseObjc/SomeClass.h:1:9: Module 'Models' not found`
Sources/UseSwift/Failure.swift:2:8: Could not build Objective-C module 'UseObjc'

Is this simply unsupported? Is there another way to accomplish this? Something like @class ... for value types?

There is a long thread discussing this issue. It's any case where Swift Package symbols, written in Swift, are added to an Objective-C header, and that header is exposed to Swift.

There is a workaround when an Xcode project is also involved using module maps mentioned in the thread. I don't know of a solution though when there are 3 Swift Package targets like you mentioned. I get the same errors.

I don't know if that's possible or not, but you may consider declaring the enum on the C (or C++) side to simplify the overall setup.

If C:

typedef NS_ENUM(NSInteger, SomeEnum) {
    SomeEnumA,
    SomeEnumB,
    SomeEnumC,
};

If C++:

enum class SomeEnum: NSInteger { // also try without ": NSInteger"
    a, b, c
};

The usage from swift should be sane in both instances:

let x: SomeEnum = .a

Thanks. Looked through there and it seems there's no good workaround available atm.

That's what I had previously but I'm hoping to move away from it.