Getter for 'subscript(dynamicMember:)' is unavailable Xcode16 #3158
-
Hi, TLDR; When trying to build our app on the Xcode 16 beta we saw a compiler error saying We've been using a struct to represent our State, the state contains an enum property which we've been marking as
This all works well in Xcode 15, but once we start using Xcode 16 we get a compiler warning saying It seems the error is coming from
FYI, I've got a sample code that I can share as well, let me know if that will be helpful. Thank you in advance |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 14 replies
-
Hi @yliu342, yes that would be very helpful. I'm having a hard time reproducing this myself. |
Beta Was this translation helpful? Give feedback.
-
@yliu342 Thanks for that! We will look into it soon. @Narsail Can you provide a small repro too for us to look at? |
Beta Was this translation helpful? Give feedback.
-
I am getting the same error when scoping an enum-based Feature inside a
This is working in Xcode 15.4.0 but results in an error in Xcode 16.0 Release Candidate (TCA version 1.15.0). public struct StreamView: View {
let store: StoreOf<StreamFeature>
public init(store: StoreOf<StreamFeature>) {
self.store = store
}
public var body: some View {
ForEach(store.scope(state: \.cardStates, action: \.card), id: \.state.id) { cardStore in
switch cardStore.state {
case .card1:
Card1FeatureView(
store: cardStore.scope(
state: \.card1, // <- Error: Getter for 'subscript(dynamicMember:)' is unavailable
action: \.card1
)
)
case .card2:
Card2FeatureView(
store: cardStore.scope(
state: \.card2, // <- Error: Getter for 'subscript(dynamicMember:)' is unavailable
action: \.card2
)
)
}
}
}
} Here is the full sample project: SubscriptXcode16Sample.zip @stephencelis Is there another way to specify the key path or to add additional information, so that the compiler can pick the right subscript overload? |
Beta Was this translation helpful? Give feedback.
@yliu342 Swift 6 has gotten a bit more strict with availability checks, which is a good thing. In your code sample Swift 5 was actually compiling some invalid code that may have only incidentally functioned. You can update your reducer with nested scoping to fix:
You may want to choose to refactor the
contentState
enum to its own reducer, though.