Search code examples
iosswiftxcode11

Cannot create instance of class when grouping in Xcode 11


I am having trouble inheriting classes when grouping swift files. For example if the file structure is like below I am able to inherit Test object.

test
|-Test.swift
|-ViewController 

However if I group the swift file then I am not able to create a instance giving me an error saying Use of unresolved identifier 'Test’

test
|-Model
    |-Test.swift
|-ViewController 

ViewController

class ViewController: UIViewController {


    let test = Test()

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.

    }
}

Test

public struct Test {
    var frameRate = 0.0
    var name: String?
}

I did not have this previously. Did something change starting from Xcode 11?


Solution

  • As in the comments this is a bug in Xcode 11. The fix is to close and reopen Xcode. and build your project. restarting might work too