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.
These views are the only views that are using custom views from TextFieldEffects
and BEMCheckbox
that I imported using Cocoapods.
You can try one of the following to figure out the cause:
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
Go to the Editor -> Debug Selected View while selecting your @IBDesignable UIView
in your storyboard, and see the stack trace.
Delete Derive Data folder.
Xcode Preference -> Location -> Derived Data
/Users/YourMacName/Library/Developer/Xcode/DerivedData
Clean your project Shift
+ Command
+ Alt
+ K
.
Build your project Command
+ B
.
I solved the problem by doing the following:
File > Workspace settings
.DerivedData
folder.DerivedData
folder, and delete the folder corresponding to your project.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.
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.
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
Adding following code to my @IBDesignable
class did the trick.
override init(frame: CGRect) {
super.init(frame: frame)
}
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)
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!
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.
Correct answer provided by @Maria:
check crash report at
~/Library/Logs/DiagnosticReports
Alternative way:
Open Spotlight
Type console.app
Select Crash reports
Check one for IBDesignablesAgent-iOS
and review crash log
My problem was solved by deleting folders (which is related to this project) from the derived data folder.
You can do this by:
Clicking menu File → Project Setting
Click the arrow sign deside /Users/.../Xcode/DerivedData.
Click the DerivedData folder. You will see your project named folders. Delete those.
Quit Xcode and then open your project.
Clean the project by using this step: Product → Clean.
Then build the project: Product → Build
These will resolve these problems.
I tried clean and run the project won't solve this issue.
But Close and reopened the project did.
Just open your storyboard -> Editor -> Refresh all views. This work for me.
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.
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
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.
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
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 .
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With