Skip to content
This repository has been archived by the owner on Jun 30, 2020. It is now read-only.

Analyzer doesn't recognise IBOutlets hooked up in Objective-C super classes #21

Open
rustyshelf opened this issue Feb 5, 2017 · 7 comments

Comments

@rustyshelf
Copy link

rustyshelf commented Feb 5, 2017

Suppose you have a class: BaseCell, and it has a child FancyCell. You can hook IBOutlets from the childs XIB to the parent class, but the IBAnalyzer doesn't seem to find these, it will instead print out:
FancyCell doesn't implement a required @IBOutlet named: starredView.

To be honest I'm not sure if this is a common use case, but I thought I'd note it here in case it helps.

@fastred
Copy link
Owner

fastred commented Feb 7, 2017

Thanks for taking the time to report the issue!

If I understand correctly this case is covered in this unit test. In there we've got:

  • parent class A with @IBOutlet named label
  • subclass of A named B without any outlets
  • nib for the B class

Hard to tell what exactly is wrong but I suspect it may be one of these:

  • a base class wasn't found and parsed (e.g. it's in a different folder or written in Objective-C)
  • the relationship between base and subclass wasn't established (not sure why this would happen)
  • the property wasn't found (I saw one report about outlets/actions in extensions) or parsed as an outlet (e.g. it's not annotated with the @IBOutlet attribute)

I'm planning to add a better error reporting which should make debugging issues like this easier in the future.

@rustyshelf
Copy link
Author

rustyshelf commented Feb 8, 2017

You are correct, and yes, the base class is Objective-C hence it wasn't picked up. Makes perfect sense considering the tool does Swift only. I should have figured that out, sorry! 😂

@vhosune
Copy link

vhosune commented Feb 21, 2017

I have seen the same issue, I but all @IBOutlet are not found. I have a separate storyboard, and a UIViewController with IBOutlet referencing a view in the UIViewController and another view outside the UIViewController but linked to it and with its @IBOutlet reference in the UIViewController source

@ldiqual
Copy link

ldiqual commented Feb 23, 2017

Same issue here, we link a tableView outlet to a subclass of XLFormViewController (https://github.com/xmartlabs/XLForm), which is a third-party objC library. It seems that many people will run into this issue even if they have a 100% swift codebase but with objC third party frameworks (I guess that makes it not 100% swift then, hmmm).

@fastred fastred changed the title Analyzer doesn't recognise IBOutlets hooked up in super classes Analyzer doesn't recognise IBOutlets hooked up in Objective-C super classes Feb 23, 2017
@fastred
Copy link
Owner

fastred commented Feb 23, 2017

@ldiqual Yeah, we should look into that. Here's a possible approach:

  1. Add ObjectiveCParser class, with the same public interface as SwiftParser. We could probably leverage some 3rd party library for tokenization, e.g. pegkit. It would have to operate on both .h and .m (and possibly .mm) files.
  2. Call it from Runner passing classNameToClassMap inout variable to it.

It's a big task but possibly pretty interesting to work on.

@andywarwick
Copy link

Think I am seeing the same thing. Am subclassing a UICollectionViewController which has a collectionView IBOutlet you set in IB. This causes a warning: IBOutlet missing: collectionView is not implemented in MySubclass.storyboard. Obviously this IBOutlet isn't in my subclass, and seems to be no way of ignoring the error.

@pokchy
Copy link

pokchy commented Feb 1, 2018

In Xcode 9.2 and Swift 4 there is the same issue.
I got a parent and child class both have IBOutlets. My view with IBOutlets is of class from the child. Connecting in Interface Builder is no problem.

After compiling code there is this warning: IBOutlet unused in the parent class.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants