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

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

    This happened to me and after reading the log in issue navigator I found out that I have two swift files with same name. This was creating the issue and I was getting build failed.

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

    1) Identify the file there the problem is. You can copy and paste the compilation instruction to the console and the last screen will contain the error description. Note the pid number there the problem was identified. Then scroll up and find the pid and related instruction - there will be one file per pid, so you will find the file you have problem it.

    2) Look through the file and check all you last changes. If you have git initialized you can use

    git diff <file name>
    
    0 讨论(0)
  • 2020-12-05 02:27

    I got this error due to a missing file in my project. Added this file again and voila everything worked.

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

    had a horrible time with this bug for over 3 hours by meticulously going from file to file and reverting the changes and seeing if that file had the issue in it. I tried the first answer but didn't give me any answers. Found the issue and it was because I had a non computed property named the same as a computed property of a subclass. I really hope the debugger becomes more robust with handling these sorts of cases in future updates :(

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

    This happened to me when trying to reference a method from an inmutable protocol argument(by mistake, I thought the member was a property):

    Having an interface as follows:

    public protocol NSValidatedUserInterfaceItem {
      func tag() -> Int
    }
    

    Compilation crash

    func validateUserInterfaceItem(anItem: NSValidatedUserInterfaceItem) -> Bool {
        print(anItem.tag) // oopsie, tag is a function
        return false
    }
    

    Compilation success

    func validateUserInterfaceItem(anItem: NSValidatedUserInterfaceItem) -> Bool {
      print(anItem.tag()) // this is cool for swift
      return false
    }
    
    0 讨论(0)
  • 2020-12-05 02:29

    I run into this last night and nothing above was solving my problem. I was about to do something very bad at my laptop when I saw, all by pure luck, that ONE (1) file was is text encoding set to UTF-16 ?!?! WTF??

    enter image description here

    This was the last file I was working on, and probably, one bad cut/paste "import" a strange character into the arena. I did a cut/paste of my code in this file to a bare bone text editor. I deleted the file, recreate it and paste back my code... and voilà! it work.

    So do the above, but also check your file encoding! :-)

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