Fix warning: Failed to set (lineColor) user defined inspected property on (Project.UnderlinedTextField)

93 Views Asked by At

I keep getting this warning:

2020-08-22 17:33:31.484454-0500 bob-app-ios[95799:7064579] 
Failed to set (lineColor) user defined inspected property on 
(projectName.UnderlinedTextField): [<projectName.UnderlinedTextField 0x7fbca5084e00> 
setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key lineColor.

When running my project in a simulator, this is my UnderlinedTextField class:

import UIKit

class UnderlinedTextField: UITextField {
    var isWriting = false
    let bottomLine = CALayer()
    
    func underlined() {
        self.delegate = self
        
        let width = CGFloat(1.0)
        reloadUnderlinedTextField()
        bottomLine.frame = CGRect(x: 0, y: self.frame.size.height - width, width:  self.frame.size.width, height: self.frame.size.height)
        bottomLine.borderWidth = width
        self.layer.addSublayer(bottomLine)
        self.layer.masksToBounds = true
    }
    
    func reloadUnderlinedTextField() {
        bottomLine.borderColor = isWriting ? ColorManager.PrimaryColor?.cgColor : ColorManager.Gray500?.cgColor
    }
}

extension UnderlinedTextField: UITextFieldDelegate {
    func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
        let maxLength = 1
        let currentString: NSString = (textField.text ?? "") as NSString
        let newString: NSString =
            currentString.replacingCharacters(in: range, with: string) as NSString
        return newString.length <= maxLength
    }
    
    func textFieldDidBeginEditing(_ textField: UITextField) {
        isWriting = true
        reloadUnderlinedTextField()
    }
    
    func textFieldDidEndEditing(_ textField: UITextField) {
        isWriting = false
        reloadUnderlinedTextField()
    }
}

Should I worry about it? How could I fix it?

I also get this warning:

2020-08-22 17:33:32.683970-0500 projectName[95799:7064579] Can't find keyplane that supports type 4 
for keyboard iPhone-PortraitChoco-NumberPad; using 25752_PortraitChoco_iPhone-Simple-Pad_Default

My app is not crashing but I feel like those warnings should be taken care of, so, any help might be really appreciated.

2

There are 2 best solutions below

0
Muhammad Waqas On BEST ANSWER

If you are expecting lineColor on UnderlinedTextField then you need to add following code

@IBInspectable var lineColor: UIColor? {
    didSet {
        //do something here
    }
}

You also need to add @IBDesignable designation above your class, when applied to a UIView or NSView subclass, as it lets Interface Builder know that it should render the view directly in the canvas. This allows seeing how your custom views will appear without building and running your app after each change. More details can be found here

If you don't need lineColor on UnderlinedTextField then:

  1. Search (⌘ + ⇧ + F) for lineColor in xib(s) and Storyboard(s)
  2. Find where you have assigned class UnderlinedTextField to UITextfield(s) Go to Identity Inspector
  3. Remove lineColor under User Defined Runtime Attributes
  4. Build and Run

enter image description here

As for the second warning please visit here.

0
Kstin On

As i know, You can't silence this warning

2020-08-22 17:33:32.683970-0500 projectName[95799:7064579] Can't find keyplane that supports type 4 
for keyboard iPhone-PortraitChoco-NumberPad; using 25752_PortraitChoco_iPhone-Simple-Pad_Default

About lineColor, You need to select your UnderlinedTextField in Storyboard and remove lineColor property from this -> enter image description here

I'm practically sure that You will find it there