5

All objects disappear in view controller (main storyboard) when I use custom @IBDesignable UITextfield class. Main storyboard looks like this:

enter image description here

(Xcode 10, Swift 4.2)
As you see, it shows an error also. But Xcode shows 'Build Succeeded' when I run the app.

I use custom @IBDesignable UITextfield class like this below:

import UIKit
import AKMaskField

@IBDesignable

class MyTextFieldStyle: AKMaskField {

@IBInspectable var secureEntry : Bool = false

@IBInspectable var myBorderColor : UIColor = UIColor.white {
    didSet {
        self.layer.borderColor = myBorderColor.cgColor
    }
}

@objc func secureButtonPressed (sender: UIButton) {
    self.secureEntry = !self.secureEntry
    self.isSecureTextEntry = self.secureEntry
}

override func awakeFromNib() {
    super.awakeFromNib() 

    if self.secureEntry {

        let btn = UIButton(type: .custom)
        btn.setImage(#imageLiteral(resourceName: "eye-17-glyph-16"), for: .normal)
        btn.addTarget(self, action: #selector(self.secureButtonPressed(sender:)), for: .touchUpInside)
        btn.sizeToFit()

        btn.frame = CGRect(x: self.frame.size.width-(btn.frame.size.width+5), y: (self.frame.size.height-btn.frame.size.height)/2, width: btn.frame.size.width, height: btn.frame.size.height)

        self.addSubview(btn)
    }

    self.layer.borderColor = self.myBorderColor.cgColor
}
}

It becomes fine when I close and open Xcode. It looks like a bug. This was working fine.

Cœur
  • 37,241
  • 25
  • 195
  • 267
mannyCalavera
  • 593
  • 1
  • 4
  • 23
  • Are you running macOS Mojave 10.14 beta 11 on your machine? –  Sep 23 '18 at 21:49
  • Dear, @Alex7 Version 10.0 (10A255) – mannyCalavera Sep 23 '18 at 21:50
  • Yeah, I know that's the Xcode version you're using, but what about your macOS version? –  Sep 23 '18 at 21:50
  • sorry, macOS High Sierra, Version: 10.13.6 (17G65) – mannyCalavera Sep 23 '18 at 21:51
  • More than likely it seems like an Xcode 10.0 bug, especially since it was working fine not too long ago. Restarting Xcode seems tedious but may be your only resolve for now until they release a patch for this. –  Sep 23 '18 at 21:56
  • There is only one error Alex. It says "Failed to render and update auto layout status for RegsigerViewController (Rve-no-pOK): The agent crashed Main.storyboard" But it can work with this error. I mean Xcode shows 'Build Succeeded' when i run the app @Alex7 – mannyCalavera Sep 23 '18 at 22:00
  • What version of cocoapods are you running? If its 1.5.0, downgrade to 1.4.0. –  Sep 23 '18 at 22:06
  • Dear, @Alex7, I googled an error explanation and then I follow these steps in the link below. Now It works. https://stackoverflow.com/questions/39732312/xcode-8-ib-designables-failed-to-render-and-update-auto-layout-status-the-a – mannyCalavera Sep 23 '18 at 22:08
  • By the way, pod version is 1.5.3 @Alex7 – mannyCalavera Sep 23 '18 at 22:09
  • Did you have to upgrade or downgrade to fix your issue for @IBDesignable? –  Sep 23 '18 at 22:09
  • No upgrade no downgrade. I just follow steps in the link. (Actually this is my mistake because i did not focus error explanation. I just thought that this is an Xcode bug. Because i got this error after i update Xcode, it was working fine) Link: https://stackoverflow.com/questions/39732312/xcode-8-ib-designables-failed-to-render-and-update-auto-layout-status-the-a – mannyCalavera Sep 23 '18 at 22:12
  • Looks like Xcode 10.1 Beta has a fix for your issue regarding @IBDesignable. Read the release notes and tell me what you think. https://developer.apple.com/documentation/xcode_release_notes/xcode_10_1_beta_release_notes –  Sep 24 '18 at 18:43
  • Dear @Alex7, yesterday it was a busy day. I just noticed that it happens again when I switch another view controller in main.storyboard and then I delete "DerivedData" like in the link and then all objects appear again. The link which i have shared yesterday: https://stackoverflow.com/questions/39732312/xcode-8-ib-designables-failed-to-render-and-update-auto-layout-status-the-a – mannyCalavera Sep 25 '18 at 12:12
  • As you wrote, Xcode 10.1 Beta has a fix this issue. Let me try it if i can download it. – mannyCalavera Sep 25 '18 at 12:14
  • Hey @Manny, did Xcode 10.1 Beta fix the issue? –  Sep 25 '18 at 21:31
  • @Alex7, Unfortunately Xcode beta shows also the same mistake: Failed to render and update auto layout status for SampleViewController (Rve-nopOK): The agent crashed Main.storyboard but Build Succeed – mannyCalavera Sep 26 '18 at 06:53

0 Answers0