Xcode 11.4 - Archiving project - Segmentation Fault 11

一世执手 提交于 2020-05-10 04:12:12

问题


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 was receiving this exception, and the archive logs helped me understand that it was within a particular SwiftUI file. By process of elimination, it turns out I had left contentInsets() and alwaysBounceVertical() modifiers on a VStack that wasn't part of a List:

VStack {
    // more stuff
}
.contentInsets(UIEdgeInsets(top: 20, left: 0, bottom: 0, right: 0))
.alwaysBounceVertical()

Removing these modifiers allowed the release archive to complete successfully.



来源:https://stackoverflow.com/questions/60865057/xcode-11-4-archiving-project-segmentation-fault-11

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!