Xcode 8 - IB Designables - Failed to render and update auto layout status, The agent crashed

I recently upgraded to Xcode 8 and I am having issues with the Storyboard.

If I open the project and I don't have the Storyboard open, it will compile and run just fine. Once I open up the Storyboard, I get multiple errors about IB Designables as shown below.

enter image description here

These views are the only views that are using custom views from TextFieldEffects and BEMCheckbox that I imported using Cocoapods.


Solution 1:

You can try one of the following to figure out the cause:

  1. look for the IBDesignablesAgentCocoaTouch logs in this directory: ~/Library/Logs/DiagnosticReports and see the cause.

Note: for user with Catalina: look for IBDesignablesAgent-iOS_<DATE>-<MAC_NAME>.crash

  1. Go to the Editor -> Debug Selected View while selecting your @IBDesignable UIView in your storyboard, and see the stack trace.

  2. Delete Derive Data folder.

    Xcode Preference -> Location -> Derived Data
    /Users/YourMacName/Library/Developer/Xcode/DerivedData
    
  3. Clean your project Shift + Command + Alt + K.

  4. Build your project Command + B.

Solution 2:

I solved the problem by doing the following:

  1. Go to File > Workspace settings.
  2. Click the little right arrow beside "Derived data". This opens the Finder app at the location of the DerivedData folder.
  3. Go inside the DerivedData folder, and delete the folder corresponding to your project.
  4. Quit Xcode, and re-open it.
  5. Clean your project shiftcommandk.
  6. build your project commandb.
  7. Open your storyboard.
  8. Go to Editor > Refresh all views.

Updated

Sometimes just directly Go to Editor > Refresh all views worked. If Refresh all views is disabled, quit Xcode and try again.

Solution 3:

I just delete the view that is failed and press command+Z to undo deletion. It works for me.

If editing the failed view later, the error may occur again, do the above again.

Solution 4:

I faced this issue in CocoaPod 1.5.0. The solution is to reinstall pod again (pod install again) once this error showing or you may use CocoaPod 1.4.0 instead. It works fine in 1.4.0 (at least for me.)

update:

Add following script in Podfile help me solve the issue in 1.5.0

post_install do |installer|
  installer.pods_project.build_configurations.each do |config|
    config.build_settings.delete('CODE_SIGNING_ALLOWED')
    config.build_settings.delete('CODE_SIGNING_REQUIRED')
  end
end

reference: https://github.com/Skyscanner/SkyFloatingLabelTextField/issues/201#issuecomment-381915911

Solution 5:

Adding following code to my @IBDesignable class did the trick.

override init(frame: CGRect) {
    super.init(frame: frame)
}