   }
 }
 
-private class BannerViewController: UIViewController, ObservableObject {
-  @Published var viewWidth: CGFloat?
+protocol BannerViewControllerWidthDelegate: AnyObject {
+  func bannerViewController(_ bannerViewController: BannerViewController, didUpdate width: CGFloat)
+}
+
+class BannerViewController: UIViewController {
+
+  weak var delegate: BannerViewControllerWidthDelegate?
 
   override func viewDidAppear(_ animated: Bool) {
     super.viewDidAppear(animated)
 
-    viewWidth = view.frame.inset(by: view.safeAreaInsets).size.width
+    delegate?.bannerViewController(
+      self, didUpdate: view.frame.inset(by: view.safeAreaInsets).size.width)
   }
 
   override func viewWillTransition(

}

private struct BannerView: UIViewControllerRepresentable {
  @StateObject private var bannerViewController = BannerViewController()
  private let bannerView = GADBannerView()
  private let adUnitID = "ca-app-pub-3940256099942544/2435281174"

  func makeUIViewController(context: Context) -> some UIViewController {
    bannerView.adUnitID = adUnitID
    bannerView.rootViewController = bannerViewController
    bannerViewController.view.addSubview(bannerView)
    bannerView.delegate = context.coordinator

    return bannerViewController
  }

  func updateUIViewController(_ uiViewController: UIViewControllerType, context: Context) {
    guard let viewWidth = bannerViewController.viewWidth else { return }

    bannerView.adSize = GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth(viewWidth)
    bannerView.load(GADRequest())
  }

  func makeCoordinator() -> Coordinator {
    Coordinator()
  }

  fileprivate class Coordinator: NSObject, GADBannerViewDelegate {
    func bannerViewDidReceiveAd(_ bannerView: GADBannerView) {
      print("DID RECEIVE AD")
    }

    coordinator.animate { _ in
      // do nothing
    } completion: { _ in
      self.delegate?.bannerViewController(
        self, didUpdate: self.view.frame.inset(by: self.view.safeAreaInsets).size.width)
    }
  }
}
