It looks like Xcode 16 has changed this behavior so I'm not sure if this is a bug or not.
When a SwiftUI Button wraps a UIButton, the button doesn't work on iOS 18.0+
import SwiftUI
struct ContentView: View {
var body: some View {
VStack {
Button(action: {
print("Not called on iOS 18")
}) {
WrapperButton()
.frame(width: 200, height: 50)
}
}
}
}
struct WrapperButton: UIViewRepresentable {
func makeUIView(context: Context) -> some UIView {
let button = UIButton(type: .system)
button.setTitle("OK", for: .normal)
return button
}
func updateUIView(_ uiView: UIViewType, context: Context) {}
}
This occurs with the app build with Xcode 16 and running on iOS 18 but it was worked with Xcode 15 builds and running on iOS 18