简体   繁体   English

Xcode 11.4 - 归档项目 - 分段错误 11

[英]Xcode 11.4 - Archiving project - Segmentation Fault 11

I Just updated Xcode to 11.4 and when archiving a project it shows me 'Segmentation Fault 11'我刚刚将 Xcode 更新到 11.4,在归档项目时,它向我显示“Segmentation Fault 11”

This project would archive with Xcode 11.3.1 but now it doesn't..该项目将使用 Xcode 11.3.1 进行存档,但现在没有了。

Anyone else ran into the same issue?其他人遇到过同样的问题吗?

在此处输入图片说明

Edit: April 15th 2020编辑:2020 年 4 月 15 日

Apple just released Xcode 11.4.1苹果刚刚发布了 Xcode 11.4.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 .在我的情况下,当我将Release 的Enable Testability设置更改为YES时,问题就消失了。

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.不,我不知道这在存档或发布版本中有什么缺点,或者确实为什么这个特殊设置可以缓解问题,但归根结底,我有一个项目花了一年时间才达到这个阶段我非常渴望将其提供给内部 Beta 测试人员,因此我将通过试飞提交它,看看我会如何。

My feeling is this is definitely an Apple bug, as the compiler should not be Seg Faulting at all.我的感觉是这绝对是 Apple 的错误,因为编译器根本不应该是 Seg Faulting。 The fact it compiles under the Debug configuration lends support to this.它在 Debug 配置下编译的事实为此提供了支持。 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.我的项目太大了,我不知道如何重现这个来提交错误,但我会看看我是否能在 Apple 论坛上得到一些回应。

For me helped to find the problem when I set in build settings the SWIFT_COMPILATION_MODE to wholemodule .对我来说,帮助我在构建设置的设置来查找问题SWIFT_COMPILATION_MODEwholemodule 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.就我而言,init 输入参数集使用了三元运算符。 Seems like Swift 5.2 don't support it anymore.似乎 Swift 5.2 不再支持它了。

// Leads to error with Xcode 11.4
init(value: UIColor = Constants.staticBoolean ? .white : .green)

In my case I had an error with Eureka pod就我而言,Eureka pod 出现错误

Segmentation fault: 11 (in target 'Eureka' from project 'Pods')

In Pods file I've provided latest version:在 Pods 文件中,我提供了最新版本:

pod 'Eureka', '~> 5.2.1'

Also set SWIFT_COMPILATION_MODE set to wholemodule . SWIFT_COMPILATION_MODE设置为wholemodule

Like other responders, there was a SwiftUI issue buried in the error messages here (using Xcode 11.4).与其他响应者一样,此处的错误消息中存在一个 SwiftUI 问题(使用 Xcode 11.4)。 In my case, use of .embedInScrollView() was causing the build error.就我而言,使用.embedInScrollView()会导致构建错误。 Disabling those calls fixed it.禁用这些调用修复了它。 As a workaround, I put .embedInScrollView() into a ViewModifier, like this:作为一种解决方法,我将.embedInScrollView()放入 ViewModifier 中,如下所示:

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.这意味着您仍然可以嵌入 scrollView 但 Seg 11 错误消失了。

I had two same name variables with @Published.我有两个与@Published 同名的变量。 Xcode 11.4.1 compiler couldn't detect 'two same variables'- instead it returned Segmentation fault 11. Xcode 11.4.1 编译器无法检测到“两个相同的变量”——而是返回了分段错误 11。

@Published var isVirtualRacing = UserDefaults.isVirtualRacing {
  willSet {
  UserDefaults.isVirtualRacing = newValue
  }
}

@Published var isVirtualRacing = UserDefaults.isVirtualRacing {
willSet {
  UserDefaults.isVirtualRacing = newValue
  }
}

你应该阅读所有的错误

我将#imageLiteral(resourceName: "image_name")更改为UIImage(imageLiteralResourceName: "image_name")

I was having the error with Eureka我在使用 Eureka 时遇到了错误

The only thing that fixed the error was the temporary solution of WilsonGramer唯一修复错误的是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 “我找到了一种解决方法,将 RowType.swift 中的 [unowned self] 替换为 [weak self] 并强制展开 self。这可以防止编译器在 Xcode 11.4 中崩溃——如果你想看一看,你可以使用我的叉子: 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项目维护者,如果这是一个合适的修复程序,请告诉我,我将打开一个拉取请求!” WilsonGramer

I hope it works for you我希望这个对你有用

The solution was very simple.解决方案非常简单。 Go to Xcode menu in : Product -> Scheme -> Edit Scheme... Select Build on the left menu.转到 Xcode 菜单中的: Product -> Scheme -> Edit Scheme...在左侧菜单中选择Build And check Build Options - Find Implicit Dependencies should be turned ON.并检查构建选项- 应打开查找隐式依赖项 Photo of example示例照片

For people who get this error because of the Eureka library, the Eureka project has a separate branch called xcode12 that fixes this issue.对于因 Eureka 库而出现此错误的人,Eureka 项目有一个名为xcode12的单独分支来解决此问题。 It compiles on Xcode 12 without problems.它在 Xcode 12 上编译没有问题。

https://github.com/xmartlabs/Eureka/tree/xcode12 https://github.com/xmartlabs/Eureka/tree/xcode12

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"; ).一个临时解决方法(直到 Apple 修复 Xcode 11.4 Swift 编译器问题)是在失败的目标( SWIFT_OPTIMIZATION_LEVEL = "-Onone";SWIFT_OPTIMIZATION_LEVEL = "-Onone";优化级别设置为“无优化”以进行发布。 It works on our project, which is split into multiple frameworks.它适用于我们的项目,该项目分为多个框架。 Just one need to be set to -Onone .只需要将一个设置为-Onone

But the Apple documentation asks to not shipping your code with this flag .但是Apple 文档要求不要使用此标志传送您的代码 It's for development, it performs minimal optimizations and preserves all debug info.它用于开发,它执行最少的优化并保留所有调试信息。

I think we have to wait :'(我想我们必须等待:'(

I have two variables ( AnyCancellable and a @Published ) with the same name in my ObservableObject object.我的ObservableObject对象中有两个AnyCancellable变量( AnyCancellable和一个@Published )。 That was run in xCode 11.5那是在 xCode 11.5 中运行的

For me, the problem was in one of the Remote Swift Package (Xcode 12).对我来说,问题出在 Remote Swift Package (Xcode 12) 之一。 I just dragged the package to the project and the problem solved.我只是将包拖到项目中,问题就解决了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM