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

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

提交回复
热议问题