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

前端 未结 25 2904
被撕碎了的回忆
被撕碎了的回忆 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:18

    As for @Kampal, I'm still struggling to figure out how much to specify in a function call. For instance, creating a UIColor object sometimes requires that UIColor be specified, and sometimes doesn't.

    These both work:

    playButton.backgroundColor = .darkGrayColor()
    playButton.setTitleColor(UIColor.whiteColor(), forState: UIControlState.Normal)
    

    This yields the exit code 1 error on compilation, without any debugger warning. #time-sucking debug vortex

    playButton.setTitleColor(.whiteColor(), forState: UIControlState.Normal)  
    

    So I have a new rule: when using a function that takes more than one parameter, be explicit.

    Now back to playing swift: AVOID THE VORTEX

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

    Unfortunately this error is often caused by a glitch inside Swift's compiler. It is not always easy to find the reason. If cleaning doesn't work, my suggestion is to try to comment the last code you wrote (even the whole file if necessary). Usually commenting the last code you entered would restore the compilation and you'll get more meaningful errors. From there on you have to try to uncomment the code piece by piece until you get to the instruction which caused this error. The Swift compiler is still pretty young and from time to time it reports weird errors. These kind of errors are completely useless, because instead of helping the developers they only confuse them even more. I would suggest Apple to change the compiler to give more detailed information and avoid this annoying error from appearing anymore.

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

    In my case I had renamed a file. After committing I found that the file name still hasn't changed in the Xcode project (not sure why), the file was greyed out. Changing the name and committing again did the trick.

    So we have to keep an eye out for this error, when making changes to files using source control.

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

    Another solution for this issues is to check that you don't have 2 or more files with the same file names. It solved the problem for me.

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

    I just had this same error, the problem was that I had overridden a method with a non-optional parameter and had made the parameter optional in the override. (the method parameter below)

    func logNetworkCallDurationForMethod(method:String, path:String, milliseconds: UInt) {
    
    }
    
    override func logNetworkCallDurationForMethod(method:String?, path:String, milliseconds: UInt) {
    
    }
    
    0 讨论(0)
  • 2020-12-05 02:23

    Ran into this issue today actually. Was the result of a recent pull from git on a project where a file had been deleted, but it didn't update in my local project.

    Clicking on the error brought up the location of the "missing" file, went and deleted it's reference in the Project Navigator. Fixed the error, did a clean, and compiled successfully.

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