Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode 10 beta2: Cannot invoke initializer for type 'UIView' with no arguments

I have downloaded Xcode 10 beta2 and rebuild my project, codes such as:

let someView = UIView()

come up with the following error:

Cannot invoke initializer for type 'UIView' with no arguments

Error Snapshort

Pretty strange. Has anybody encountered those building errors when using Xcode 10 beta2?

like image 606
hustlzp Avatar asked Jul 01 '18 14:07

hustlzp


1 Answers

For me it was reasoned by extending NSObjectProtocol:

extension NSObjectProtocol where Self: UIView

I fixed it by replacing NSObjectProtocol to any other protocol that UIView conforms. In my case it was UIAppearance:

extension UIAppearance where Self: UIView
like image 143
Serge Vysotsky Avatar answered Sep 27 '22 19:09

Serge Vysotsky