Adding interstitial ads into SpriteKit game swift

| | August 10, 2015

I’m trying to implement interstitial ads with iAd into my spriteKit game. My code is as follows:

class MainViewController: UIViewController, ADInterstitialAdDelegate {

var interAd = ADInterstitialAd()
var interAdView: UIView!

var closeButton = UIButton.buttonWithType(UIButtonType.System) as! UIButton

override func viewDidAppear(animated: Bool) {

closeButton.frame = CGRectMake(10, 10, 20, 20)
    closeButton.layer.cornerRadius = 10
    closeButton.setTitle("x", forState: .Normal)
    closeButton.setTitleColor(UIColor.blackColor(), forState: .Normal)
    closeButton.backgroundColor = UIColor.whiteColor()
    closeButton.layer.borderColor = UIColor.blackColor().CGColor
    closeButton.layer.borderWidth = 1
    closeButton.addTarget(self, action: "close:", forControlEvents: UIControlEvents.TouchDown)

func close(sender: UIButton) {
func loadAd() {
    println("load ad")
    interAd = ADInterstitialAd()
    interAd.delegate = self
func interstitialAdDidLoad(interstitialAd: ADInterstitialAd!) {
    println("ad did load")

    interAdView = UIView()
    interAdView.frame = self.view!.frame



func interstitialAdDidUnload(interstitialAd: ADInterstitialAd!) {


func interstitialAd(interstitialAd: ADInterstitialAd!, didFailWithError error: NSError!) {
    println("failed to receive")



This code delivers me more problems than it does results. Unfortunately I am a beginner at implementing any sort of ads into an app and I don’t know how I can change any of this in my favour.

One issue I get is that output traces ad did load (as you can see thats supposed to be traced once the ad is presented) however when ad did load is traced no ad is presented. I wait for at least 3 minutes but nothing happens.

Another issue I have is this WARNING: More than 10 instances of ADBannerView or ADInterstitialView currently exist. This is a misuse of the iAd API, and ad performance will suffer as a result. This message is printed only once., but this is printed after the function to load the ad is called once or twice.

Any help is more than appreciated.

Leave a Reply