可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
I Just updated Xcode to 11.4 and when archiving a project it shows me 'Segmentation Fault 11'
This project would archive with Xcode 11.3.1 but now it doesn't..
Anyone else ran into the same issue?
Edit: April 15th 2020
Apple just released Xcode 11.4.1
回答1:
I have run into the same issue. Archiving uses the Release building configuration so I went through every compiler setting to work out which of the differences lead to these Segmentation faults.
In my case the problem disappears when I change the setting Enable Testability to YES for Release.
No I have no idea what the downsides to this are in the archive or release build, or indeed why this particular setting alleviates the problem, but at the end of the day, I have a project that has taken a year to get to this stage and I'm very keen to get this to internal beta testers so I am going to submit this through test flight and see how I go.
My feeling is this is definitely an Apple bug, as the compiler should not be Seg Faulting at all. The fact it compiles under the Debug configuration lends support to this. My project is so large that I don't know how to reproduce this to submit a bug, but I'll see if I can get some response on the Apple Forums.
回答2:
For me helped to find the problem when I set in build settings the SWIFT_COMPILATION_MODE
to wholemodule
. Then after compiling got a more specific error which led to class function which caused the error.
Afterward changed it back as it was.
Maybe it helps you also.
In my case, there was used ternary operator for init input param set.
Seems like Swift 5.2 don't support it anymore.
// Leads to error with Xcode 11.4
init(value: UIColor = Constants.staticBoolean ? .white : .green)
回答3:
Like other responders, there was a SwiftUI issue buried in the error messages here (using Xcode 11.4). In my case, use of .embedInScrollView()
was causing the build error. Disabling those calls fixed it. As a workaround, I put .embedInScrollView()
into a ViewModifier, like this:
public struct WrapInScrollView: ViewModifier {
public func body(content: Content) -> some View {
content
.embedInScrollView()
}
public init() {}
}
Then I use that modifier a bit like the original call, like this:
.modifier(WrapInScrollView())
This means you can still embed in a scrollView but the Seg 11 errors go away.
回答4:
In my case I had an error with Eureka pod
Segmentation fault: 11 (in target 'Eureka' from project 'Pods')
In Pods file I've provided latest version:
pod 'Eureka', '~> 5.2.1'
Also set SWIFT_COMPILATION_MODE
set to wholemodule
.
回答5:
I changed #imageLiteral(resourceName: "image_name")
to UIImage(imageLiteralResourceName: "image_name")
回答6:
Unfortunately, the Enable Testability solution did not work for me.
A temporary workaround (until Apple will fix the Xcode 11.4 Swift compiler issue) is to turn the Optimization Level to "No Optimization" for Release, on the target that fails (SWIFT_OPTIMIZATION_LEVEL = "-Onone";
). It works on our project, which is split into multiple frameworks. Just one need to be set to -Onone
.
But the Apple documentation asks to not shipping your code with this flag. It's for development, it performs minimal optimizations and preserves all debug info.
I think we have to wait :'(
回答7:
I had two same name variables with @Published. Xcode 11.4.1 compiler couldn't detect 'two same variables'- instead it returned Segmentation fault 11.
@Published var isVirtualRacing = UserDefaults.isVirtualRacing {
willSet {
UserDefaults.isVirtualRacing = newValue
}
}
@Published var isVirtualRacing = UserDefaults.isVirtualRacing {
willSet {
UserDefaults.isVirtualRacing = newValue
}
}
回答8:
I was having the error with Eureka
The only thing that fixed the error was the temporary solution of WilsonGramer
The solution is the next:
"I found a workaround for this by replacing [unowned self] in RowType.swift with [weak self] and force-unwrapping the self. This prevents the compiler from crashing in Xcode 11.4 — if you'd like to take a look you can use my fork: https://github.com/Wilsonator5000/Eureka/tree/fix/xcode11.4-unowned-self
Project maintainers, if this is a suitable fix please let me know and I'll open a pull request!" WilsonGramer
I hope it works for you