Reputation: 2015
I am studying Swift! I want create Main interface on xib. But have error "use of unresolved identifier".
Add code from MainViewController
import Foundation
public class MainViewController : BaseViewController {
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
// TODO: Write your test code here
// ...
} }
Upvotes: 6
Views: 33926
Reputation: 378
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.
Upvotes: 2
Reputation: 3905
Just a tip for those who found this question with this issue like mine.
This issue tortured me for days! 😭 I can run the project but the red error sign kept showing up. At first blamed this to Xcode (Sorry, Xcode).
But after I read all the answers in this thread and checked my source file's Target Membership
, I realized that I was wrong to blame Xcode.
The file where this issue was reported had three Target Membership
: the main one, the one for tests and another for ui tests. But the variable it refer to was in a file that had only one Target Membership
, the main one.
So to recap: check the Target Membership
of the file where issue is reported, and of the one where the unresolved identifier
is declared. Make sure Membership
the later contains that of the formal.
Upvotes: 0
Reputation: 9835
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:
Upvotes: 0
Reputation: 1441
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 :)
Upvotes: 18