команда не удалась из-за ошибки сегментации сигнала 11 Xcode 9 - симулятор iOS

Мой код компилируется в Xcode 9.3 с помощью swift 4.1, я могу запустить свой код на устройстве, но при попытке запустить этот код на симуляторе выдает следующую ошибку:

введите здесь описание изображения

Я пробовал так много решений, доступных для этой ошибки, но ни одно из них не сработало для меня.

У меня есть следующий код в моем быстром файле, который вызывает эту ошибку:

import Foundation
import UIKit


extension UITableView {

  func register<T: UITableViewCell>(_: T.Type) where T: ReusableView, T: NibLoadableView {
    self.register(T.nib, forCellReuseIdentifier: T.reuseIdentifier)
  }

  func registerClass<T: UITableViewCell>(_: T.Type) where T: ReusableView, T: NibLoadableView {
    self.register(T.self, forCellReuseIdentifier: T.reuseIdentifier)
  }

  func dequeueReusableCell<T: UITableViewCell>(forIndexPath indexPath: IndexPath) -> T? where T: ReusableView {
    guard let cell = self.dequeueReusableCell(withIdentifier: T.reuseIdentifier, for: indexPath) as? T else {
      fatalError("Could not dequeue cell with identifier: \(T.reuseIdentifier)")
    }
    return cell
  }

}


extension UICollectionView {

  func register<T: UICollectionViewCell>(_: T.Type) where T: ReusableView {
    self.register(T.self, forCellWithReuseIdentifier: T.reuseIdentifier)
  }

//  func register<T: UICollectionViewCell where T: ReusableView, T: NibLoadableView>(_: T.Type) {
//    self.register(T.nib, forCellWithReuseIdentifier: T.reuseIdentifier)
//  }

  func dequeueReusableCell<T: UICollectionViewCell>(forIndexPath indexPath: IndexPath) -> T? where T: ReusableView {
    guard let cell = self.dequeueReusableCell(withReuseIdentifier: T.reuseIdentifier, for: indexPath) as? T else {
      fatalError("Could not dequeue cell with identifier: \(T.reuseIdentifier)")
    }

    return cell
  }

}

// MARK: Add to superView with autoresizingMask(FlexibleWidth and FlexibleHeight)
extension UIView {

  func getKeyboardFrame(_ keyboardNotification: Notification) -> CGRect {
    guard let info  = keyboardNotification.userInfo else { return CGRect(x: 0, y: 0, width: 0, height: 0) }
    let value: AnyObject = info[UIKeyboardFrameEndUserInfoKey] as AnyObject

    let rawFrame = value.cgRectValue
    return self.convert(rawFrame!, from: nil)
  }

  // MARK: Get UIView from Nib
  class func getNibView<T: UIView>() -> T? where T: NibLoadableView {
    return Bundle.main.loadNibNamed(T.nibName, owner: self, options: nil)?[0] as? T
  }
  /// Add a view to a superview with the view's frame equal to the superview's bounds and the view having autoresizing mask enabled.
  func add(to superView: UIView) {
    self.frame = superView.bounds
    self.autoresizingMask = [
      .flexibleWidth,
      .flexibleHeight
    ]
    superView.addSubview(self)
  }
}

Этот код содержит несколько предупреждений при компиляции введите здесь описание изображения

Я хочу запустить код на симуляторе, но не могу этого сделать.


person Pramod More    schedule 05.06.2018    source источник
comment
Код изначально был написан в Swift 2.2, и я обновляю его для компиляции в Swift 4.   -  person Pramod More    schedule 13.06.2018


Ответы (1)


Я думаю, что это настоящие проблемы с компилятором. Попробуйте внести небольшие изменения, пока это не сработает.

person Wizard of Kneup    schedule 05.06.2018
comment
Да, я думаю, вы правы. После многократных ошибок сборки я смог запустить код на симуляторе. Без каких-либо изменений. - person Pramod More; 06.06.2018