[Feature Request] No HelperCoder generated when check compilation condition
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- swift
- Domain
- build-system
Research direction
Start by reproducing the reported build in a Swift package using the swiftSettings compilation condition and the provided ResponseAttributes and Response declarations. Read the macro and plugin paths that generate ResponseAttributesCoder, then check how they handle declarations inside #if conditions. Done means the conditional example compiles and generates the coder without breaking the working example.
Written by the indexing model from the issue text.
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
- Dominant language
- Swift
- Stars
- 779
- Forks
- 46
- Avg merge
- 9h 7m
- Merged PRs (30d)
- 2
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from SwiftyLab/MetaCodable
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
SwiftyLab/MetaCodable#169 ·
-
enhancement good first issue
Difficulty 4/5 3-5 days Newbie friendliness 32/100
SwiftyLab/MetaCodable#49 · 5 comments · 2 reactions ·
All issues in SwiftyLab/MetaCodable
Similar issues
-
needs-triage S3: minor
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
manaflow-ai/cmux#28422 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 65/100
SwiftOldDriver/iOS-Weekly#5480 ·
-
Seed a JRNYAx price before the last close so asset-detail S1.3 doesn't fail from 08:00Z to the openOpenbug tests
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
lognorman20/monaco#7231 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 5 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Maintainers usually reply within 7 days