0

I noticed that at a given point the class User could not be found when I wanted to use it in other classes. Nothing suspicious about it. At a given point I started to experiment with what place I put the code.

If I put all these classes together in one of my older files, all compiles. If I put them all together in a newer file, the other parts of my code consuming these classes do not compile. If I rename a file (from User.swift to AUser.Swift for example) nothing changes, meaning what compiles keeps compiling and what doesn't compile still doesn't compile based on name. It really seems to be the age of the file or something like that.

It appears as if everything I add later related to this particular cluster of classes will not compile in a newer file. These files are included when building, I checked that. There is nothing strange about the code I think:

import UIKit

public class User: AddressBookContact {
    var home: Home?
    var friends = [Friend]()
}



public class Friend: AddressBookContact {

}



class Session: NSObject {
    private static let instance = Session()

    override private init() {
        super.init()
    }

    class func sharedInstance() -> Session {
        return instance
    }

    static var loggedInUser: User?
}
Lucas van Dongen
  • 9,328
  • 7
  • 39
  • 60
  • "Does not compile" is meaningless. Show the code that errors and say what error you are getting! – matt Aug 18 '15 at 15:43
  • Also why are your classes `public`? Are you using modules / frameworks here? That could certainly be the source of the issue! - And show the definition of AddressBookContact, please. – matt Aug 18 '15 at 15:44

1 Answers1

1

Look in the File Inspector Utility pane (the right-hand pane). The file in question likely is not a member of the target.

Rob Napier
  • 286,113
  • 34
  • 456
  • 610
  • Accepted since you put me in the right direction, please change your answer to reflect the true solution. What happened is that there is a Project and a ProjectTest project and some of the classes that referred to Friend were included in the test (without using the Friend class by itself in the tests). But the error didn't appear in the Test project but in the main project which put me totally on the wrong foot. I needed to add the Friend.swift file to the test project in order to make it compile for the whole project. – Lucas van Dongen Aug 18 '15 at 19:03