I have this issue with my code.
I have some code that bridges a C library I wrote.
The code I'm trying to compile is this.
import SharedEngineC
import Shared
import SharedC
open class Game: CObject<GamePtr>, JSONCode {
convenience init(
code: Code,
id: Int,
randomizer: Randomizer? = nil,
owner: User
) throws {
self.init(
ptr: try Error.handle({ error in
return .init(
code: code.ptr,
id: UInt64(id),
randomizer: randomizer?.ptr,
owner: owner.ptr,
error: error)
}))
}
}
But when I try to compile it, the compiler complains with the error Generic class 'CObject' requires that 'UserPtr' conform to 'CObjectPtr'
.
However when I look at the "header"-file for Shared
, I can see that it is clearly there and is public.
extension UserPtr : Shared.CObjectPtr, Shared.CJSONCoder, Shared.CHashable, Shared.CEntity {
public typealias Item = Shared.User
}
But the compiler cannot see it.
If I add it manually in the file like this it will work.
import SharedEngineC
import Shared
import SharedC
extension UserPtr: CObjectPtr {
public typealias Item = User
}
open class Game: CObject<GamePtr>, JSONCode {
convenience init(
code: Code,
id: Int,
randomizer: Randomizer? = nil,
owner: User
) throws {
self.init(
ptr: try Error.handle({ error in
return .init(
code: code.ptr,
id: UInt64(id),
randomizer: randomizer?.ptr,
owner: owner.ptr,
error: error)
}))
}
}
What am I doing wrong. Do I need to set some compiler flag in order for the Swift compiler to see the public extension?