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

时间:2018-09-08 06:33:25

标签: 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. 在Flow.swift:9:3发出'navigateInFlow(_ :)'的SIL时
  2.   
  3. silgen发出Function SIL函数“ @ $ S12module12FilePAASo41ViewcontrollerAnimatedTransitionRzrlE010navigateInE0yySSF”时。   在Flow.swift:9:3出现'navigate(_ :)'错误:分段错误:11
  4.   

有人可以帮忙吗?

谢谢。

1 个答案:

答案 0 :(得分:0)

我遇到了这个问题,并通过更改包含带有默认值的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
        })
    }