Swift subclassing ObjC Class, initializer gets recognized selector

Viewed 174

The problem is simple. I have a Swift class that subclasses an Objective-C class:

class CJGADSearchBannerView: GADSearchBannerView {
    ...
}

Then I initialize my class as:

let searchBanner = CJGADSearchBannerView(adSize: kGADAdSizeFluid)

The inherited Objective-C class comes from the GoogleMobileAdsSDK pod.

It all compiles fine and I can trace the initializer back to its original class in the code:

@interface GADSearchBannerView : GADBannerView

Then:

GAD_SUBCLASSING_RESTRICTED
@interface GADBannerView : UIView

#pragma mark Initialization

/// Initializes and returns a banner view with the specified ad size and origin relative to the
/// banner's superview.
- (instancetype)initWithAdSize:(GADAdSize)adSize origin:(CGPoint)origin;

/// Initializes and returns a banner view with the specified ad size placed at its superview's
/// origin.
- (instancetype)initWithAdSize:(GADAdSize)adSize;

But at runtime I get:

-[CJGADSearchBannerView initWithAdSize:]: unrecognized selector sent to instance 0x7f87cbe88710

It used to work, then at some point I built in Xcode 10 and it just broke.

I tried adding @ObjcMembers to the new class in case it was an inference issue, I tried deleting DerivedData in case it was linking to old code, I deleted Pods and ran pod install again, I tried switching between Swift 3 and Swift 4, I tried building in Xcode 9.4 and Xcode 10, but nothing worked.

0 Answers
Related