Swift - “use of unresolved identifier”

前端 未结 4 1183
迷失自我
迷失自我 2020-12-07 01:57

I am studying Swift! I want create Main interface on xib. But have error \"use of unresolved identifier\".

Add code from MainViewController

相关标签:
4条回答
  • 2020-12-07 02:33

    1) Right Click your MainViewController.swift

    2) Select Show File Inspector

    3) On Right side panel, look at Target Membership

    4) Add your class to target by check the box :)

    0 讨论(0)
  • 2020-12-07 02:34

    Just a tip for those who found this question with this issue like mine.

    This issue tortured me for days!

    0 讨论(0)
  • 2020-12-07 02:50

    You likely didn't add the class to the target. Click on the MainViewController class and open the utilities tab on the upper right corner in Xcode:

    Make sure the appropriate target is checked.

    EDIT: Apparently you don't have target membership there - which is bizarre in and of itself. Try re-creating the MainViewController class from scratch and make sure the correct target is selected:

    0 讨论(0)
  • 2020-12-07 02:56

    This same issue happened with me too. I've only one target membership and still, I was getting “use of unresolved identifier”. I build the project and nothing changed.

    I tried to uncheck and recheck the target membership and the issue was resolved.

    If this doesn't resolve your issue, try building the project, check for typo error or use autocompletion and Quick Help to find recognized identifiers.

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