A project using SwiftUI fails archiving and throws the very cryptic message Bus error: 10
, without further explanation.
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
. 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.
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. 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
:
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 } }
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.