swift failed with exit code 1 while compiling in Xcode - possibly related to Bridging-Headers

前端 未结 25 2905
被撕碎了的回忆
被撕碎了的回忆 2020-12-05 02:00

I have an Obj-C Project I\'m trying to migrate to Swift. I did succeed with various classes but recently ran into an issue I can\'t seem to make sense of. When I try to comp

相关标签:
25条回答
  • 2020-12-05 02:29

    Since everyone else has been showing theirs, I'll show mine:

    class Foo : UIView {
        var pathPosition:Double = 0.0 { didSet {
            pathPosition = min(max(0.0, pathPosition), 1.0) // crashes if this line is present
            self.pathPosition = min(max(0.0, pathPosition), 1.0) // but not here
            }}
    }
    

    Incredibly, this does not come up in Playground, but does fail when placed in code in a framework. Although it is legal syntax (used to work, still works in playground), the Swift compiler seems to want pathPosition to be qualified with self.. Note that is (relatively) old code and used to compile, maybe something broke in 6.1.

    Edit:

    I feel like I am going insane, but it feels like there is a greater complexity problem going on here, where surrounding code can impact this problem. I saw things compile last night, changed some code and settings again today, and it failed on me again. Today, I had to hack in a bunch of really stupid code to get it to work:

    var pathPosition:Double = 0.0 { didSet {
    
        // bug: insane!! - have to clobber the value before resetting!
        let bugOldValue = pathPosition
        self.pathPosition = 1.0 // fails without this nonsensical line!
        self.pathPosition = min(max(0.0, bugOldValue), 1.0)
    }}
    

    For what it's worth, the actual error message I got, per the helpful instructions above, was:

    PHI node has multiple entries for the same basic block with different incoming values!
    %14 = phi double [ 1.000000e+00, %10 ], [ %11, %10 ], [ 1.000000e+00, %9 ], [ 0.000000e+00, %9 ], !dbg !4818
    label %10
    double 1.000000e+00
    %11 = phi double [ %7, %entry ], !dbg !4815
    LLVM ERROR: Broken function found, compilation aborted!
    

    I'm scared for tomorrow.

    0 讨论(0)
  • 2020-12-05 02:31

    moving the Bridge file to project level resolve my problem.

    0 讨论(0)
  • 2020-12-05 02:34
    NSString const *kGreenColor = @"#00C34E"; 
    

    I had above line in my Constant.h file. which was meant for preprocessors only. Removing that line worked for me.

    0 讨论(0)
  • 2020-12-05 02:35

    I had CoreData generated files twice (and added myself). Check the files are not duplicate.

    0 讨论(0)
  • 2020-12-05 02:36

    I had accidentally dragged symlinks (aliases) to source files into the project instead of the actual files.

    0 讨论(0)
  • 2020-12-05 02:39

    In my case deleted a couple of files directly from SourceTree but their reference was still there in Xcode. Logs show their names. Removed them and error went away.

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