可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
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.
回答1:
You can try one of the following to figure out the cause:
look for the IBDesignablesAgentCocoaTouch
logs in this directory:
~/Library/Logs/DiagnosticReports
and see the cause.
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
.
回答2:
I solved the problem by doing the following:
- Go to
File > Workspace settings
.
- Click the little right arrow beside "Derived data". This opens the Finder app at the location of the
DerivedData
folder.
- Go inside the
DerivedData
folder, and delete the folder corresponding to your project.
- Quit Xcode, and re-open it.
- Clean your project shiftcommandk.
- build your project commandb.
- Open your storyboard.
- 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.
回答3:
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
回答4:
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.
回答5:
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.
回答6:
my problem was solved by deleting folders (which is related to this project) from derived data folder.
you can do this by clicking File -> Project Setting ->
then click the arrow sign deside /Users/.../Xcode/DerivedData
click DerivedData folder you will see your project named folders delete those . quit xcode the open your project , clean the project by using this step Product->clean
then build the project : Product->Build
These will resolve this problems .
回答7:
Adding following code to my @IBDesignable
class did the trick.
override init(frame: CGRect) {
super.init(frame: frame)
}
回答8:
When i debugged this i found out there are some classes which are modifying 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 fixed width or height for these custom views. If it doesn't solve your problem try Following solutions:-
Solution 1: - Uncomment #use_frameworks inside your pod file.
Solution 2: - Try deleting derived data
- Close Editor window of your Xcode and quit simulator ->
- Go to Xcode Preferences -> Locations ->
- Click small grey arrow showing derived data path ->
- Select your project ->
- Delete all the folders inside ->
- Quit Xcode and reopen
回答9:
Just open your storyboard -> Editor -> Refresh all views.
This work for me.
回答10:
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.
回答11:
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.
回答12:
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.