Alan
Alan

Reputation: 9481

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.

Upvotes: 190

Views: 114444

Answers (24)

Srinivasan_iOS
Srinivasan_iOS

Reputation: 1088

I have faced this problem We can use this solution and it's worked for me

Solution:

  1. Delete the Derived data

    Xcode Preferences -> Location -> Derived Data /Users/YourMacName/Library/Developer/Xcode/DerivedData

  2. Quit Xcode and reopen Xcode.

  3. Clean the build folder. Xcode -> Product -> Clean Build Folder...

Upvotes: 0

Mitu Vinci
Mitu Vinci

Reputation: 465

My problem was solved by deleting folders (which is related to this project) from the derived data folder.

You can do this by:

  1. Clicking menu FileProject Setting

  2. Click the arrow sign deside /Users/.../Xcode/DerivedData.

  3. Click the DerivedData folder. You will see your project named folders. Delete those.

  4. Quit Xcode and then open your project.

  5. Clean the project by using this step: ProductClean.

  6. Then build the project: ProductBuild

These will resolve these problems.

Upvotes: 9

hbk
hbk

Reputation: 11184

Correct answer provided by @Maria:

check crash report at ~/Library/Logs/DiagnosticReports

Alternative way:

  1. Open Spotlight

    Enter image description here

  2. Type console.app

    enter image description here

  3. Select Crash reports

    Enter image description here

  4. Check one for IBDesignablesAgent-iOS and review crash log

Upvotes: 7

Diego Salcedo
Diego Salcedo

Reputation: 81

In my case, I faced this problem because I was using a class that generated that error. Just stop using that and the problem will be solved!

This was the class I was using. I changed for UIView and then the error disappeared:

Enter image description here

Upvotes: 1

Saif
Saif

Reputation: 2968

For me it was due to incorrect Font Name in Storyboard. Correcting the font name fixed the issue.

Discarding the below change fixed the issue.

InCorrectFont

Upvotes: 0

Karsten
Karsten

Reputation: 1939

My first try of exiting Xcode and relaunching helped.

So it is some easy quick-fix instead of some work ,-)

Upvotes: -1

LatinCoder
LatinCoder

Reputation: 81

Try to disable 'Use Trait Variations' (Identity and Type panel) for any xib file that you might have for custom views that are used in your storyboard.

Upvotes: 8

Ashish P
Ashish P

Reputation: 1473

When I debugged this, I found out there are some classes which are modifying the UI. Typically marquelabel which is a subclass of UILabel or any other class subclassing UIView and drawing UI at run time and colliding with Autolayout engine. Try giving a fixed width or height for these custom views. If it doesn't solve your problem try the following solutions:

Solution 1: Uncomment #use_frameworks inside your pod file.

Solution 2: Try deleting derived data

  1. Close the Editor window of your Xcode and quit the simulator
  2. Go to Xcode PreferencesLocations
  3. Click the small grey arrow showing the derived data path
  4. Select your project
  5. Delete all the folders inside
  6. Quit Xcode and reopen

Upvotes: 3

Tak Rahul
Tak Rahul

Reputation: 176

In my @IBDesignable class crashed because I used the custom class for the color and forced unwrapped the colours propertied that's @IBDesignable class found nil while unwrap

So you need to find the IBDesignablesAgent-iOS_[Date]_[YourMac].crash on ~/Library/Logs/DiagnosticReports this location and you will get the reason of the crash with the respected file path.

Now you have to check the respected file.

Upvotes: 2

eNeF
eNeF

Reputation: 3280

This is the easiest way for me: add this script to your Podfile

Podfile:

post_install do |installer|
  installer.pods_project.targets.each do |target|
    next if target.product_type == "com.apple.product-type.bundle"
    target.build_configurations.each do |config|
      config.build_settings['CONFIGURATION_BUILD_DIR'] = '$PODS_CONFIGURATION_BUILD_DIR'
    end
  end
end

Source:

This workaround for @IBDesignable can be found here: https://github.com/CocoaPods/CocoaPods/issues/5334

Upvotes: 0

Maria
Maria

Reputation: 4611

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.

Upvotes: 206

Stelabouras
Stelabouras

Reputation: 454

For anyone -like me- who can't find that IBDesignablesAgentCocoaTouch file or when trying to 'Debug Selected Views' from the Editor gets an error, here's another way to debug those "Failed to render" errors.

Open the 'Console' app, from the sidebar select your current Mac (it will probably be auto-selected by default) and then on the search bar search for "IBSceneUpdate" and hit enter.

This way, every time you get an Xcode error for an IBDesignable not being able to render, you will also get a new "IBSceneUpdate" entry with more details about the error.

That's at least how I was able to debug my IBDesignable errors!

Console app showing IBSceneUpdate errors

Upvotes: 16

Lal Krishna
Lal Krishna

Reputation: 16200

I tried clean and run the project won't solve this issue.

But Close and reopened the project did.

Upvotes: 6

Mehsam Saeed
Mehsam Saeed

Reputation: 275

I faced this problem after update to latest XCode version .After trying multiple solution described above ,i only quite Xcode and then shut down system and turn it on and that worked for me .

Upvotes: 1

Avinash
Avinash

Reputation: 51

Faced same Error: Had customised UITextField and using interface builder, the error in console was -Use of unimplemented initializer 'init(frame:)' for class "CustomField"

Added the initialiser to fix the error

Upvotes: 1

If you're using xib file for custom uiview. Try this:

Change from

Bundle.main.loadNibNamed("UserView", owner: self, options: nil)

To:

let bundle = Bundle(for: UserView.self) 
bundle.loadNibNamed("UserView", owner: self, options: nil)

Upvotes: 17

Nox
Nox

Reputation: 1583

I had the same issue and came here to try and figure out what happened. I noticed the top rated answer and the answer itself didn't help me, as IBDesignable didn't exist in the log folder and I already attempted all other options there, however in the comments I noticed someone talking about a frame init.

I decided to try commenting out my IBDesignable extension for UIView and it instantly fixed the problem. So, to fix this, find the extension causing the issue and make sure to set up the required inits by creating an IBDesignable class and providing the required initializers as follows:

@IBDesignable class RoundedView: UIView {

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

required init?(coder aDecoder: NSCoder) {
    super.init(coder: aDecoder)
    sharedInit()
}

override func prepareForInterfaceBuilder() {
    super.prepareForInterfaceBuilder()
    sharedInit()
}

func sharedInit() {
}
}

IMPORTANT: remember to add the new class to the item you are using the designable on.

Upvotes: 4

Zaid Pathan
Zaid Pathan

Reputation: 16820

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

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

Upvotes: 19

yancaico
yancaico

Reputation: 1281

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.

Upvotes: 61

Jerome Li
Jerome Li

Reputation: 1586

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

Upvotes: 37

axunic
axunic

Reputation: 2316

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.

Upvotes: 102

Anggara Siswanajaya
Anggara Siswanajaya

Reputation: 41

Just open your storyboard -> Editor -> Refresh all views. This work for me.

Upvotes: 4

AnthoPak
AnthoPak

Reputation: 4391

In my case, I was using a library which was subclassing UIView. It was using IB_DESIGNABLE, and was missing call to [super awakeFromNib]. Once I've added the call to this method, the bug went away.

I'm not sure if the fact that it was implementing IB_DESIGNABLE had an impact in this.

Upvotes: 0

Alberto Lopez
Alberto Lopez

Reputation: 247

After you make the necessary changes, change the storyboard or in my case a .xib to open in "XCode 7", save and close. This is just a stop gap measure to address the errors but ultimately you will need to fix them or do this until you are no longer able to.

Upvotes: 0

Related Questions