ios - swift ios 扩展使用 xcode10 给出段错误 11

标签 ios swift segmentation-fault xcode10

我正在使用 swift 3.1、xcode 10 beta、cocapods 1.5.3

extension WithdrawFlow where Self: ViewcontrollerAnimatedTransition {
func navigate()
 ...
}

但编译器在扩展所在的行崩溃主要是由于使用了“where Self: ViewcontrollerAnimatedTransition”

xcode 9 工作正常。但 xcode 10 在下面给出:

  1. While emitting SIL for 'navigateInFlow(_:)' at Flow.swift:9:3
  2. While silgen emitFunction SIL function "@$S12module12FilePAASo41ViewcontrollerAnimatedTransitionRzrlE010navigateInE0yySSF". for 'navigate(_:)' at Flow.swift:9:3 error: Segmentation fault: 11

有人可以帮忙吗?

谢谢。

最佳答案

我遇到了这个问题,通过更改包含具有默认值的 inout 参数的函数解决了这个问题。告诉我错误的函数是我的应用程序中第一次调用它的地方。

旧:

 /// Creates a new Icon button with the specified tint color, image and pulse animation
    convenience init(withTintColor tint: inout BehaviorRelay<UIColor> = UIColor.navBarTintColor,
                     tintedImage: UIImage?,
                     pulseAnimation: PulseAnimation = .centerRadialBeyondBounds
        ) {
        self.init(image: tintedImage?.withRenderingMode(.alwaysTemplate))
        self.pulseAnimation = pulseAnimation
        _ = (tint ?? UIColor.navBarTintColor).asObservable().subscribe(onNext: { [weak self] (newColor) in
            self?.tintColor = newColor
            self?.imageView?.tintColor = newColor
        })
    }

新:

 /// Creates a new Icon button with the specified tint color, image and pulse animation
    convenience init(tintedImage: UIImage?,
                     pulseAnimation: PulseAnimation = .centerRadialBeyondBounds
        ) {
        self.init(image: tintedImage?.withRenderingMode(.alwaysTemplate))
        self.pulseAnimation = pulseAnimation
        _ = UIColor.navBarTintColor.asObservable().subscribe(onNext: { [weak self] (newColor) in
            self?.tintColor = newColor
            self?.imageView?.tintColor = newColor
        })
    }

关于ios - swift ios 扩展使用 xcode10 给出段错误 11,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52232691/

相关文章:

ios - 禁用滚动时如何确定 UICollectionView 宽度

ios - AudioKit:如何对AKPlayer进行调频

ios - 如何定义向外设发送命令的正确数据格式?

ios - 文件存在于主线程上,但后台线程表示不存在(iOS)

gcc - 迭代和取消引用未对齐的内存指针会导致段错误吗? GCC 优化器中的错误?

iphone - 首先为 iPhone 4 或 5 开发

ios - 如何在 Kotlin Multiplatform Mobile 中使用 Swift 中 Flow 中的密封类数据?

macos - 为什么窗口背景在全屏时保持黑色?

c - GDB 中的段错误 "in ?? ()"

C指针-Segment错误的解决办法是什么