I would like to show an adMob banner. I think I've configured adMob correctly but when I launch the app it crashes giving the famous error: Thread 1: Fatal error: Unexpectedly found nil while unwrapping an Optional value . I don't know what I am doing wrong. The error is on the line banner1.adUnitID = "ca-app-pub-1314395885924826/98794********"
ViewController.swift:
import UIKit
import Foundation
import MessageUI
import Firebase
import GoogleMobileAds
class ViewController: UIViewController, MFMailComposeViewControllerDelegate {
@IBOutlet weak var banner1: GADBannerView!
override func viewDidLoad() {
banner1.adUnitID = "ca-app-pub-1314395885924826/98794********" //Thread 1: Fatal error: Unexpectedly found nil while unwrapping an Optional value
banner1.rootViewController = self
banner1.load(GADRequest())
// Do any additional setup after loading the view, typically from a nib.
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.