[英]Xcode Bus error: 10 when archiving but working fine on debug
A project using SwiftUI fails archiving and throws the very cryptic message Bus error: 10
, without further explanation.使用SwiftUI的项目归档失败并抛出非常神秘的消息Bus error: 10
,无需进一步解释。
But everything works fine while debugging.但是调试时一切正常。
After some fiddling with the project Build Settings , specifically the differences between Debug and Release modes I narrowed the problem to be around Optimization Level
.在对项目构建设置进行了一些摆弄之后,特别是调试和发布模式之间的差异,我将问题缩小到Optimization Level
。 Using Optimize for Speed [-0]
(my Release configuration) will throw the error, but if I change it to No Optimization [-0none]
the error is gone and I can archive.使用Optimize for Speed [-0]
(我的发布配置)会抛出错误,但如果我将其更改为No Optimization [-0none]
,错误就会消失,我可以存档。
How can I fix the problem without compromising optimization?如何在不影响优化的情况下解决问题?
After long research and reading this answer I was able to narrow the issue even further.经过长时间的研究和阅读这个答案,我能够进一步缩小问题的范围。 It turned out I had a SwiftUI
EquatableView
, but without properties.原来我有一个SwiftUI
EquatableView
,但没有属性。 Something like this:像这样的东西:
struct MyEquatableView: View, Equatable { var body: some View { // some content } static func == (lhs: Self, rhs: Self) -> Bool { // some logic } }
All I had to do was adding a "dummy property" to my View
:我所要做的就是在我的View
中添加一个“虚拟属性”:
struct MyEquatableView: View, Equatable { private let id = UUID() // dummy property var body: some View { // some content } static func == (lhs: Self, rhs: Self) -> Bool { // some logic } }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.