Open
Description
- I have read the documentation.
Describe the bug
Below code works well.
working code
@Codable
@CodedAs<String?>
@CodedAt("operation")
protocol ResponseAttributes {}
@Codable
struct Response {
@CodedIn("data")
let id: String
@CodedIn("data")
let type: String
@CodedIn("data")
@CodedBy(ResponseAttributesCoder())
let attributes: ResponseAttributes
}
@Codable
struct RegistrationAttributes: ResponseAttributes, DynamicCodable {
static var identifier: DynamicCodableIdentifier<String?> { .one("REGISTRATION") }
let id: String
@CodedAt("status-code")
let statusCode: String
let operation: String
}
@Codable
struct VerificationAttributes: ResponseAttributes, DynamicCodable {
static var identifier: DynamicCodableIdentifier<String?> { .one(nil) }
let id: String
let operation: String?
let expiresIn: UInt
@CodedAt("xxx-token")
let xxxToken: String
@CodedAt("yyy-token")
let yyyToken: String
}
But the ResponseAttributesCoder
will be missing if add #if SOME_SWIFT_ACTIVE_COMPILATION_CONDITION
.
Xcode say 'Cannot find 'AnonymousAttestationResponseAttributesCoder' in scope'.
failed to work
// Have set the `SOME_SWIFT_ACTIVE_COMPILATION_CONDITION` in `swiftSettings` from `Package.swift`.
#if SOME_SWIFT_ACTIVE_COMPILATION_CONDITION
@Codable
@CodedAs<String?>
@CodedAt("operation")
protocol ResponseAttributes {}
@Codable
struct Response {
@CodedIn("data")
let id: String
@CodedIn("data")
let type: String
@CodedIn("data")
@CodedBy(ResponseAttributesCoder())
let attributes: ResponseAttributes
}
@Codable
struct RegistrationAttributes: ResponseAttributes, DynamicCodable {
static var identifier: DynamicCodableIdentifier<String?> { .one("REGISTRATION") }
let id: String
@CodedAt("status-code")
let statusCode: String
let operation: String
}
@Codable
struct VerificationAttributes: ResponseAttributes, DynamicCodable {
static var identifier: DynamicCodableIdentifier<String?> { .one(nil) }
let id: String
let operation: String?
let expiresIn: UInt
@CodedAt("xxx-token")
let xxxToken: String
@CodedAt("yyy-token")
let yyyToken: String
}
#endif
To Reproduce
Steps to reproduce the behavior:
- Create an empty swift package
- Add MetaCodable to dependencies
- Copy and paste the code above
- commnad + B
Expected behavior
Compilation condition check shouldn't fail plugin or macro.
Environment (please complete the following information, remove ones not applicable):
- OS: macOS
- Version 13.6.6
- Xcode 15.2
- Swift 5.9.2