问题
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

Pretty strange. Has anybody encountered those building errors when using Xcode 10 beta2?
回答1:
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
回答2:
try this
let someView = UIView(frame: CGRect.zero)
it works for me
回答3:
Just add the "frame" argument: UIView(frame: CGRect.zero) (or whatever you need it to be)
In my code I set up the Views like this and later I add constraints (which basically override frame parameters).
The same works for UIView, UILabel, UIScrollView and others... For UIButtons, add the "type" argument instead: UIButton(type: UIButtonType.custom)
回答4:
After hours of debugging I have finally found the problem.
I use a pod SwiftTheme, after upgrading it to a new version those errors have gone.
See this commit.
来源:https://stackoverflow.com/questions/51124370/xcode-10-beta2-cannot-invoke-initializer-for-type-uiview-with-no-arguments