I have the following code
import UIKit
class CustomButton: UIButton {
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
self.theme_setTitleColor(GlobalPicker.customButtonTextColor, forState: .normal)
self.theme_setTitleColor(GlobalPicker.customButtonDisabledTextColor, forState: .disabled)
self.theme_backgroundColor = GlobalPicker.primaryColor
self.layer.cornerRadius = self.frame.height/4.0
self.clipsToBounds = true
}
override init(frame: CGRect) {
super.init(frame: frame)
self.layer.cornerRadius = self.frame.height/2.0
self.clipsToBounds = true
}
}
And I'm getting errors when trying to build this code with Xcode 10. The code works just fine with Xcode 9 and Swift 4.0. I was hoping for a seamless transition but apparently that's not what I'm getting.

Is this an Xcode 10 bug? Anyone else running into anything similar?
My guess is that there's an extension somewhere in one of the targets of your project or workspace that messes with UIButton in a way that cripples it somehow. (The fact that this is possible is clear, and I regard it as a bug; see https://bugs.swift.org/browse/SR-2935 and the related duplicates, including https://bugs.swift.org/browse/SR-3228, and mine at https://bugs.swift.org/browse/SR-8010.)
You might be able to slide around the extension by subclassing UIKit.UIButton instead of simple UIButton. For the reason why this works, see the comment discussion in my duplicate bug report. When an extension behaves this way, it overloads methods, and you can distinguish the UIButton that doesn't have the overloads by using the module namespace.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With