Search code examples
swifttvosundefined-symbolgoogle-ima

Undefined symbols for architecture "_OBJC_CLASS_$_IMACompanionAdSlot"


This target is tvOS. I'm using Cocoapods and here is the pod

pod 'GoogleAds-IMA-tvOS-SDK', '4.3.2'

I've tried updating to a more recent version, but the issue remained.

Undefined symbols for architecture arm64:
    "_OBJC_CLASS_$_IMACompanionAdSlot", referenced from:
        objc-class-ref in DAILinearTVPlayer.o
        objc-class-ref in NativePlayer.o
ld: symbol(s) not found for architecture arm64

This is the error I get when I try to build my target with SWIFT_OPTIMIZATION_LEVEL = "-Onone".

When I change only the optimization level to SWIFT_OPTIMIZATION_LEVEL = "-O" build is successful.

I've tried most of the answers from this question and also this question but nothing worked in my case.

When I try to build for simulator I get the same error except "... for architecture x86_64"


Solution

  • I was using wrong init for IMAAdDisplayContainer

    IMAAdDisplayContainer(adContainer: self.view, viewController: self, companionSlots: nil)
    

    companion slots aren't supported on tvOS here is comment about this. After I've changed init to

    IMAAdDisplayContainer(adContainer: self.view, viewController: self)
    

    Everything compiled successfully in Debug configuration and without optimizations. Finally I can use debugger normally again!