Constraint items must each be a view or layout guide

Replace

toItem: view.safeAreaLayoutGuide.bottomAnchor,

With

toItem: view.safeAreaLayoutGuide,

Or

toItem: view,

You specify an anchor while as the exception says it must be a usual view or a layoutGuide


The error is in the first constraint. The correct formulation in iOS 12 is:

NSLayoutConstraint(item: bannerView,
                   attribute: .bottom,
                   relatedBy: .equal,
                   toItem: view.safeAreaLayoutGuide,
                   attribute: .bottom,
                   multiplier: 1,
                   constant: 0)

It means that the attribute bottom of the bannerView has to be equal to the bottom attribute of the view.safeAreaLayoutGuide.

Tags:

Ios

Admob