Search code examples
xcodeswiftswift2ios9xcode7-beta5

Swift 2.0 / Xcode 7B5 - Classes can only be found if put in a certain file


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?
}

Solution

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