Swift compiler segmentation fault when building

后端 未结 30 2274
南旧
南旧 2020-11-29 03:59

Adding a (convenient) computed height property to UIView in my UIViewExtension.swift file is causing the Swift compiler to segfault...

相关标签:
30条回答
  • 2020-11-29 05:01

    I’ve discovered a simple workaround until the problem is fixed in a future Xcode/Swift build:

    • Simply place all extensions causing the issue in the .swift file that it’s being used.

    In the example project you provided, place the contents of UIViewExtension.swift and CALayerExtension.swift above AppDelegate.swift

    Hopefully this can get us to write working Swift code until the problem’s cleared up.

    0 讨论(0)
  • 2020-11-29 05:01

    As for me, adding private to static var fixed clang crash:

    private static var taskId = 0
    
    0 讨论(0)
  • 2020-11-29 05:02

    In my case, this error because I use Class name for variable

    var MYClass : MYClass {
        get {
            return.....
        }
    }
    

    And this fixes my problem

    var myClass : MYClass {
        get {
            return.....
        }
    }
    
    0 讨论(0)
  • 2020-11-29 05:02

    For me the issue was having my architectures not set to the standard. I had added i386 or something, just set it back to default xcodeproject arch and it compiled fine.

    0 讨论(0)
  • 2020-11-29 05:03

    I had a compiler segmentation fault on a statement like this:

    someFunction(isFlagged ? "String1" : "String2")
    

    I just did a if-else statement instead and it works.

    0 讨论(0)
  • 2020-11-29 05:03

    As others wrote above, for me this happened when I'm using an extension over a protocol but the signature of methods in the protocol don't match the implementations in an extension.

    In my case, I had added a new parameter to the implementation (in the extension) but forgot to also add it to the method's signature in the protocol.

    0 讨论(0)
提交回复
热议问题