So I have been making an app, and everything has been working great. But today I made a new class like usual and for some reason in this class I can't access Public/Global variable from other classes. All the other classes can, but now when ever I try to make a new class I can't. How would this be fixed?
I am using Swift and Xcode 6.
Working Class:
import UIKit import Foundation import Parse import CoreData var signedIn = true class ViewController: UIViewController {
New Class:
import UIKit class NewClass: UIViewController { override func viewDidLoad() { super.viewDidLoad() signedIn = false }
But on signedIn = false
I get the error:
use of unresolved identifier "signedIn"
Use of unresolved identifier is such a compile-time error, because the error arises when compiling your app. Conversely, a run-time error is an error that occurs while you run your app. So… Use of unresolved identifier really means: “You're using a framework, class, function, property, or variable Xcode doesn't know!”
The identifier is undeclared: In any programming language, all variables have to be declared before they are used. If you try to use the name of a such that hasn't been declared yet, an “undeclared identifier” compile-error will occur. Example: #include <stdio.h> int main()
One possible issue is that your new class has a different Target or different Targets from the other one.
For example, it might have a testing target while the other one doesn't. For this specific case, you have to include all of your classes in the testing target or none of them.
Once I had this problem after renaming a file. I renamed the file from within Xcode, but afterwards Xcode couldn't find the function in the file. Even a clean rebuild didn't fix the problem, but closing and then re-opening the project got the build to work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With