Xcode shows many errors but program compiles and runs fine (in both simulator and device)

后端 未结 16 1360
陌清茗
陌清茗 2020-12-23 13:46

After installing the CocoaLumberjack\' log compressor class I\'ve been getting this annoying behavior: Xcode complains that there are many undeclared identifiers and gives m

相关标签:
16条回答
  • 2020-12-23 14:11

    I had it on Xcode 10.1 when I accidentally pressed:

    Cmd+Shift+U - ( build for Testing )

    try Clean (Cmd+Shift+K) and then:

    Cmd+Shift+R ( build for Running )

    0 讨论(0)
  • 2020-12-23 14:11

    I had this issue recently. It can be remedied in some cases by deleting the ModuleCache folder inside DerivedData, along with the project folder in DerivedData. Note that Xcode must be quit before doing this.

    0 讨论(0)
  • 2020-12-23 14:13

    This problem can cause by setting "Target Membership" for some files are not the same.

    Example:

    A class XYZ put in file "a.swift" and it's used in file "b.swift". But "Target Membership" setting of "a.swift" is not the same "Target Membership" setting of b.swift.

    Check "Target Membership" setting as below:

    0 讨论(0)
  • 2020-12-23 14:15

    I've been running into these issues constantly on all the latest versions of Xcode, in both Objective-C and Swift.

    I noticed today that I was getting the errors in one particular class file. I removed it from some extra targets it was in and the errors finally went away!

    I think Xcode has some fundamental bugs with it's handling of multiple targets right now. My theory is that if the other target is not built, you will essentially see errors from that target. Anyway hope this helps someone.

    0 讨论(0)
  • 2020-12-23 14:17

    For me it helped cleanning the project. XCode->Product->Clean

    0 讨论(0)
  • 2020-12-23 14:21

    I finally solved this after MANY attempts using the following:

    Remove the last #import from my Prefix.pch and build again. Errors would happen (obviously). Put the line back and build again. No errors would show and after 10 seconds or so, errors would come back again.

    Repeat the above except instead of the last #import, remove the last TWO imports, then three, four, etc. I did this until I removed five imports and when I put them back and waited, Xcode stopped complaining.

    Note that this didn't occur to me at all. I read this solution on a blog somewhere.

    Weird bug...

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