Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No visible @interface for 'LifetimeConfiguration' declares the selector 'initWithMaxCount:groupName:' #34

Closed
ajfigueroa opened this issue Jan 30, 2018 · 3 comments

Comments

@ajfigueroa
Copy link
Contributor

ajfigueroa commented Jan 30, 2018

Setup

  • Xcode 9.2
  • Mixed project of Swift 4 and Objective-C
  • LifetimeTracker version 1.3.2 with a DEBUG configuration (I've also tried without this)
    • pod 'LifetimeTracker', :configurations => ['Debug']

Issue

I'm trying to conform a class to LifetimeTrackable so I've followed the steps in the README.md for Objective-C integration.

I get the above error when I try to use LifetimeConfiguration:

No visible @interface for 'LifetimeConfiguration' declares the
selector 'initWithMaxCount:groupName:'

In my file, I have imported the class as @import LifetimeTrackable.
I also tried importing as #import <LifetimeTracker/LifetimeTracker-Swift.h>. When I look at this file I see this generated interface for LifetimeConfiguration

/// Holds the properties which are needed to configure a <code>LifetimeTrackable</code>
SWIFT_CLASS("_TtC15LifetimeTracker21LifetimeConfiguration")
@interface LifetimeConfiguration : NSObject
- (nonnull instancetype)init SWIFT_UNAVAILABLE;
@end

Full generated interface file here

Has this been seen before? I took a look at the example and I was unable to reproduce the issue.

@krzysztofzablocki
Copy link
Owner

hmm weird, the code works fine in our objc example, can you try adding @objc attribution to the initializer in your local pod checkout and see if it helps, I didn't expect this to be needed but maybe ?

@ajfigueroa
Copy link
Contributor Author

ajfigueroa commented Feb 14, 2018

@krzysztofzablocki Apologies for the delay! I was able to reproduce this more reliably now that I understand it better. Adding the @objc does indeed fix the issue though.

The ExampleObjc project works fine because the pod itself is on Swift 3 as shown here.
If you run the migrator so that it converts LifetimeTracker to Swift 4 which will require no syntax change then you'll see the following deprecation warning:

screen shot 2018-02-14 at 2 07 47 pm

This matches what is happening in my project since I have a mixed Obj-C/Swift 4 codebase which requires the explicit @objc annotations. I didn't run the migrator on the Pod when I installed it but it was automatically set to Swift 4.

I can make a PR to annotate all the public methods with @objc or should it be done on a per need basis?

@krzysztofzablocki
Copy link
Owner

a PR with annotations would be great 👍

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

No branches or pull requests

2 participants