Xcode 10.2 protocol inheritance issue

We have a big issue with the current Xcode version (10.2).

There is a BasicViewController class with the following signature:
class BasicViewController: UIViewController, UITableViewDataSource, UITableViewDelegate
Then we have another class like ExampleViewController: BasicViewController which has some additional logic.

Now comes the tricky part...

We build and run the app on different simulators and devices and everything works properly. Then we archive the app and suddenly didSelectRow is not fired anymore. Deep clean and clean of the project allowed us to reproduce the issue without the need to archive again.

I cannot think of any case when this could happen. And it gets even worse, because I found more similar issues with UITableViewDelegate methods not being called in the child class only when running the archived app. Could it be an issue with some of the optimisations during archiving and submitting the app?

I verify that we set the dataSource and delegate of the table properly, there are no gesture recognisers over the table. The same logic works well after running the app second/third time, but fails first time after a deep clean of the project.

We made a test and set the UITableViewDataSource and UITableViewDelegate in the child class and then it works as expected every time. It seems inheriting the protocols does not work well. If we keep the protocols in the parent and also add them in the child class, then it says that the protocols in the child class are redundant.

Has anyone experienced anything similar? Any suggestions are welcome.

A link to the original thread in StackOverflow: https://stackoverflow.com/questions/55592341/xcode-10-2-protocol-inheritance-issue

I ran into something similar. Is it possible you're running into this issue? If so, you can probably work around it for now by explicitly adding @objc to your func tableView(_:, didSelectRowAt:) function in ExampleViewController.swift.

class ExampleViewController: BaseViewController {
    @objc // <-- add this
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    }
}
Terms of Service

Privacy Policy

Cookie Policy