Parent class public setter variable out of scope error

So in my code, my LoginViewController is a subclass of a ConversationViewController (is a part of a Swift Package that I am adding to my project). Now, ConversationVC has a setter variable declared as public, which i refer to in LoginVC.
Ideally it should not give me an error, but I am getting the following one.

Cannot find 'isChatBarHidden' in scope

isChatBarHidden is declared as a public variable and the class ConversationVC has a public init()

I have tried the usual : deleting derived data and doing a clean build, tried importing the Swift Package again after reset and resolve, but nothing seems to help with the error.

Any help with why I might be getting the error is highly appreciated!

You need to post some example code. This isn't enough information.

This is the definition of isChatBarHidden in the ConversationVC

public var isChatBarHidden: Bool = false {
    didSet {
        chatBar.isHidden = isChatBarHidden
    }
}

This is how it is being referred to in the child class.

open class LoginViewController: ConversationVC {
    open override func viewWillDisappear(_ animated: Bool) {
        super.viewWillDisappear(animated)
        isChatBarHidden = false
    }
}

On the isChatBarHidden = false line, I get the error Cannot find 'isChatBarHidden' in scope

Hmm.... this is strange. You should be able to access isChatBarHidden. Even if there was an access control issue, you should get a very specific error saying so. Try prefixing isChatBarHidden with self.. Do you have a link to the full project and package?

Yes, this is the project link.
The package can be found here

I cannot find the declaration for isChatBarHidden anywhere. Please provide a link to the line on which it appears on Github.

I think this should work : GitHub - shilwantk/spmTest

Again, I cannot find the location of this code:

public var isChatBarHidden: Bool = false {
    didSet {
        chatBar.isHidden = isChatBarHidden
    }
}

Please create a permalink to this definition and send it to me.

The Kommunicate package does not even build for me:

/Users/pschorn/Library/Developer/Xcode/DerivedData/new-bvtoyaujcwavfufwruhtslskndjl/SourcePackages/checkouts/Kommunicate-iOS-SDK/Kommunicate/Classes/KMConversationViewController.swift:141:9: error: cannot find 'isChatBarHidden' in scope
        isChatBarHidden = false
        ^~~~~~~~~~~~~~~
/Users/pschorn/Library/Developer/Xcode/DerivedData/new-bvtoyaujcwavfufwruhtslskndjl/SourcePackages/checkouts/Kommunicate-iOS-SDK/Kommunicate/Classes/KMConversationViewController.swift:388:9: error: cannot find 'isChatBarHidden' in scope
        isChatBarHidden = isAssignedToBot
        ^~~~~~~~~~~~~~~

This should work, I guess. Link to where the code is defined
ApplozicSwift/ALKConversationViewController.swift at c2f805dcf84c842f85dff1869e15671f9b78aa04 · AppLozic/ApplozicSwift · GitHub

From which project/swift package do you need to access ALKConversationViewController (which contains the isChatBarHidden property)?

The Kommunicate package, specifically the KMConversationViewController, needs the access to ALKConversationViewController.

The reason for the error is pretty obvious. In Kommunicate, you're depending on the wrong branch of ApplozicSwift:

That branch doesn't contain a declaration of the isChatBarHidden property. If you change the branch to master, then it will work. (Although this may not be the only branch with that property).

You should carefully review which branch of each dependency that you are using.

Thank you so much for helping! I will make the change and check it out.

Terms of Service

Privacy Policy

Cookie Policy