Undefined symbols for architecture "_OBJC_CLASS_$_IMACompanionAdSlot"

4.4k Views Asked by At

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"

2

There are 2 best solutions below

0
mkbrwr On BEST ANSWER

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!

1
Jack Will On

TARGET -> Build Settings, search 'VALID'. Set VALID_ARCHS. If run with a simulator set x86_64 else iPhone device set arm64.

This is work for me. You can try.