I'm using Xcode 6 + Swift.
Does anybody know how to integrate Google Ads, GoogleMobileAdsSdkiOS on a Swift Project? how to config, and how to program?
I created a new file Teste-Bridging-Header.h
on the project and put #import GADBannerView.h
based on this reference
on my ViewController.swift
some thing like:
class ViewController: UIViewController {
override func viewDidAppear(animated: Bool) {
super.viewWillAppear(animated)
var adB = GADBannerView()
adB.delegate = self
adB.rootViewController = self
adB.adUnitID = MY_ADS_ID //"ca-app-pub-XXXXXXXX/XXXXXXX"
}
}
Am I going in the right direction? Can I get some examples?
now its working...
on .h created Objective-C bridging header I put:
#import "GADBannerView.h"
#import "GADBannerViewDelegate.h"
#import "GADRequest.h"
my swift file:
class ViewController: UIViewController, GADBannerViewDelegate {
override func viewDidAppear(animated: Bool) {
super.viewWillAppear(animated)
var adB = GADBannerView( frame:CGRectMake(0, 0, 320, 50) )
adB.delegate = self
adB.rootViewController = self
adB.adUnitID = "ca-app-pub-XXXXXXX/XXXXXXXX"
var reqAdB = GADRequest()
//reqAdB.testDevices = [ GAD_SIMULATOR_ID ] //not working, dont know why
//reqAdB.testDevices = ["Simulator"] //not working, dont know why
adB.loadRequest(reqAdB)
self.view.addSubview(adB)
}
}