I have an existing codebase that was written in Swift 3 and Xcode 9 that I am having trouble migrating to Xcode 10 and Swift 4.2 due to build errors within the code.
The problem I am running into now is this:
"Expression type '@lvalue CGRect' is ambiguous without more context"
I am getting this error in 3 different areas of my code. The fourth one is related but different in that it says:
"Expression type '(CGSize) -> CGSize' is ambiguous without more context"
I have tried changing all values within the expression to explicitly use the data type CGFloat to remove any inferred data type errors, and this still did not fix the problem.
override func sizeThatFits(_ size: CGSize) -> CGSize {
let adjustedHeight = 8.0 + titleLabel.frame.height + 2.0 + underlineView.frame.height
adjustedHeight += 16.0 + mapImageView.frame.height + 16.0
return CGSize(width: bounds.width, height: adjustedHeight)
}
override func sizeThatFits(_ size: CGSize) -> CGSize {
let adjustedHeight = 10.0 + titleLabel.frame.height + 15.0 + daysRoundedView.frame.height
adjustedHeight += daysTextLabel.frame.height + 10.0 + logoImageView.frame.height + 20.0
return CGSize(width: size.width, height: adjustedHeight)
}
override func sizeThatFits(_ size: CGSize) -> CGSize {
let adjustedHeight = 8.0 + titleLabel.frame.height + 2.0
adjustedHeight += underlineView.frame.height + 16.0 + flyerImageView.frame.height + 16.0
return CGSize(width: bounds.width, height: adjustedHeight)
}
override func sizeThatFits(_ size: CGSize) -> CGSize {
let adjustedHeight = 8.0 + titleLabel.frame.height + 2.0 + underlineView.frame.height + 16.0
adjustedHeight += descriptionTextView.sizeThatFits(CGSize(width: size.width - 40, height: size.height)).height + 16.0
return CGSize(width: bounds.width, height: adjustedHeight)
}
The issue is with the adjustedHeight variable. I'm not sure if a different function or syntax is used in Swift 4.2 for this but I cannot seem to fix this error.