Repository: Automattic/pocket-casts-ios
File: podcasts/NowPlayingPlayerItemViewController.swift (Swift)

Code before:
        return controller
    }()
    #endif

    var lastShelfLoadState = ShelfLoadState()

    private var bannerAdHostingController: PCHostingController<AnyView>?
    private var bannerAdHeightConstraint: NSLayoutConstraint?

    private let analyticsPlaybackHelper = AnalyticsPlaybackHelper.shared

    override func viewDidLoad() {
        super.viewDidLoad()

        #if !APPCLIP
        let upNextPan = UIPanGestureRecognizer(target: self, action: #selector(panGestureRecognizerHandler(_:)))
        upNextPan.delegate = self
        view.addGestureRecognizer(upNextPan)

        chromecastBtn.inactiveTintColor = ThemeColor.playerContrast02()
        chromecastBtn.addTarget(self, action: #selector(googleCastTapped), for: .touchUpInside)
        chromecastBtn.isPointerInteractionEnabled = true

        routePicker.delegate = self

        if FeatureFlag.bannerAds.enabled {
            addAdBanner()
        }
        #endif
    }

#if !APPCLIP
    func addAdBanner() {
        removeBannerAd()

        guard let stackView = episodeImage.superview as? UIStackView else { return }

        let model = BannerAdModel(adText: "Listen to your favorite books while supporting your local indie bookstore",
                                  imageURL: URL(string: "https://static.pocketcasts.com/discover/images/420/9349e8d0-a87f-013a-d8af-0acc26574db2.jpg")!,
                                  linkTitle: "Libro.fm")
        let adView = BannerAdView(model: model, colors: .playerColors(Theme.sharedTheme)).padding(8)
        let hostingController = PCHostingController(rootView: AnyView(adView))

        hostingController.view.translatesAutoresizingMaskIntoConstraints = false
        hostingController.view.backgroundColor = .clear

        let targetSize = CGSize(width: stackView.bounds.width, height: UIView.layoutFittingCompressedSize.height)
        let size = hostingController.sizeThatFits(in: targetSize)

        addChild(hostingController)
        stackView.insertArrangedSubview(hostingController.view, at: 0)

Review comment (suggestion):
Question: if the whole `adAdBanner` declaration and implementation is behind `if !APPCLIP`, will this make some errors? As the function won't exist for the Appclip (I guess)

Code after:
        return controller
    }()
    #endif

    var lastShelfLoadState = ShelfLoadState()

    private var bannerAdHostingController: PCHostingController<AnyView>?
    private var bannerAdHeightConstraint: NSLayoutConstraint?

    private let analyticsPlaybackHelper = AnalyticsPlaybackHelper.shared

    override func viewDidLoad() {
        super.viewDidLoad()

        #if !APPCLIP
        let upNextPan = UIPanGestureRecognizer(target: self, action: #selector(panGestureRecognizerHandler(_:)))
        upNextPan.delegate = self
        view.addGestureRecognizer(upNextPan)

        chromecastBtn.inactiveTintColor = ThemeColor.playerContrast02()
        chromecastBtn.addTarget(self, action: #selector(googleCastTapped), for: .touchUpInside)
        chromecastBtn.isPointerInteractionEnabled = true

        routePicker.delegate = self

        if FeatureFlag.bannerAds.enabled {
            addAdBanner()
        }
        #endif
    }

    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)

        #if !APPCLIP
        // Show the overflow menu
        if AnnouncementFlow.current == .bookmarksPlayer {
            overflowTapped()
        }
        #endif
    }

    private var lastBoundsAdjustedFor = CGRect.zero

    var analyticsSource: AnalyticsSource {
        .player
    }

    var displayTranscript = false {
        didSet {
#if !APPCLIP