ios Xcode 8 - IB Designables - 无法呈现和更新自动布局状态,代理崩溃
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/39732312/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Xcode 8 - IB Designables - Failed to render and update auto layout status, The agent crashed
提问by Alan
I recently upgraded to Xcode 8 and I am having issues with the Storyboard.
我最近升级到 Xcode 8,但故事板有问题。
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.
如果我打开项目并且我没有打开 Storyboard,它会编译并运行得很好。打开 Storyboard 后,我收到多个关于 IB Designables 的错误,如下所示。
These views are the only views that are using custom views from TextFieldEffects
and BEMCheckbox
that I imported using Cocoapods.
这些视图是唯一使用自定义视图TextFieldEffects
并且BEMCheckbox
我使用 Cocoapods 导入的视图。
回答by Maria
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.
IBDesignablesAgentCocoaTouch
在此目录中查找日志:~/Library/Logs/DiagnosticReports
并查看原因。
Note: for user with Catalina: look for
IBDesignablesAgent-iOS_<DATE>-<MAC_NAME>.crash
注意:对于使用 Catalina 的用户:查找
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
.
@IBDesignable UIView
在您的故事板中选择您的时,转到编辑器 -> 调试所选视图,并查看堆栈跟踪。删除派生数据文件夹。
Xcode Preference -> Location -> Derived Data /Users/YourMacName/Library/Developer/Xcode/DerivedData
清理你的项目
Shift
+Command
+Alt
+K
。构建您的项目
Command
+B
.
回答by mnemonic23
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
.
- 去
File > Workspace settings
。 - 单击“派生数据”旁边的向右小箭头。这将在
DerivedData
文件夹位置打开 Finder 应用程序。 - 进入
DerivedData
文件夹,并删除与您的项目对应的文件夹。 - 退出 Xcode,然后重新打开它。
- 清理你的项目shiftcommandk。
- 构建您的项目commandb。
- 打开你的故事板。
- 去
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.
有时只是直接去Editor > Refresh all views
上班。如果Refresh all views
已禁用,请退出 Xcode 并重试。
回答by Ryan.Yuen
I just delete the view that is failed and press command+Z to undo deletion. It works for me.
我只是删除失败的视图,然后按 command+Z 撤消删除。这个对我有用。
If editing the failed view later, the error may occur again, do the above again.
如果稍后编辑失败的视图,可能会再次出现错误,请重新执行上述操作。
回答by Jerome Li
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.)
我在 CocoaPod 1.5.0 中遇到过这个问题。解决方案是在出现此错误时再次重新安装 pod(再次安装 pod),或者您可以改用 CocoaPod 1.4.0。它在 1.4.0 中运行良好(至少对我而言。)
update:
更新:
Add following script in Podfile help me solve the issue in 1.5.0
在 Podfile 中添加以下脚本帮助我解决 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
参考:https: //github.com/Skyscanner/SkyFloatingLabelTextField/issues/201#issuecomment-381915911
回答by Zaid Pathan
Adding following code to my @IBDesignable
class did the trick.
将以下代码添加到我的@IBDesignable
课程中就可以了。
override init(frame: CGRect) {
super.init(frame: frame)
}
回答by Stelabouras
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.
对于无法找到该IBDesignablesAgentCocoaTouch
文件或尝试从编辑器“调试选定视图”时出现错误的任何人(例如我),这里有另一种调试“无法呈现”错误的方法。
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.
打开“控制台”应用程序,从侧边栏中选择您当前的 Mac(默认情况下可能会自动选择),然后在搜索栏上搜索“IBSceneUpdate”并按 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.
这样,每次IBDesignable
由于无法渲染而收到 Xcode 错误时,您还将获得一个新的“IBSceneUpdate”条目,其中包含有关该错误的更多详细信息。
That's at least how I was able to debug my IBDesignable
errors!
这至少是我能够调试IBDesignable
错误的方式!
回答by Hoàng C?ng Tùng
If you're using xib file for custom uiview. Try this:
如果您使用 xib 文件进行自定义 uiview。尝试这个:
Change from
更改自
Bundle.main.loadNibNamed("UserView", owner: self, options: nil)
To:
到:
let bundle = Bundle(for: UserView.self)
bundle.loadNibNamed("UserView", owner: self, options: nil)
回答by LatinCoder
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.
尝试为故事板中使用的自定义视图可能拥有的任何 xib 文件禁用“使用特征变体”(身份和类型面板)。
回答by Mitu Vinci
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 .
我的问题是通过从派生数据文件夹中删除文件夹(与此项目相关)来解决的。您可以通过单击 File -> Project Setting -> 然后单击 /Users/.../Xcode/DerivedData 旁边的箭头符号单击 DerivedData 文件夹,您将看到您的项目命名文件夹删除那些 . 退出 xcode 打开你的项目,使用这个步骤清理项目 Product->clean 然后构建项目:Product->Build 这些将解决这个问题。
回答by Anggara Siswanajaya
Just open your storyboard -> Editor -> Refresh all views. This work for me.
只需打开您的故事板 -> 编辑器 -> 刷新所有视图。这对我有用。