iAds AddOn

Hi everyone,

I’ve been “developing” a game using Codea for some time now, GREAT tool! now i am finished with my game and i want to implement Ads (iAds i suppose). I’ve read all the tutorials i could find, but i cannot get it to work. can you please help?

It seems the exported x-code project has the iAdsAddOn already implemented (at least i can see files in Xcode). following the latest tutorial on codeatuts (tutorial 29), it seems it is out of date. for example in the tutorial the addon file is IAdsAddon.h (with CAPITAL “I”), in the exported project there it’s named “iAdsAddon.h”. Same for the CodeaViewController which now seems to be StandaloneCodeaViewController.

Is there any up-to-date document about how to implement iAds with the current version of “export to Xcode Projects”?

I tried to follow the tutorial and fix the naming issues myself, the app builds fine, but code runtime gives an error "attempt to call a nil value (global ‘showAdFromTop’).

here is the code (please let me know if you need more):

    //  AppDelegate.h
    //  Killemann
    //  Created by Alexander Neujahr on Sonntag, 2. Oktober 2016
    //  Copyright (c) Alexander Neujahr. All rights reserved.
    #import <UIKit/UIKit.h>
    #import "iAdsAddon.h"
    @class StandaloneCodeaViewController;
    @interface AppDelegate : UIResponder <UIApplicationDelegate>
    @property (strong, nonatomic) iAdsAddon *iAdsAddOn;
    @property (strong, nonatomic) UIWindow *window;
    @property (strong, nonatomic) StandaloneCodeaViewController *viewController;

and here is the start of AppDelegate.mm

//  AppDelegate.mm
//  Killemann
//  Created by Alexander Neujahr on Sonntag, 2. Oktober 2016
//  Copyright (c) Alexander Neujahr. All rights reserved.

#import "AppDelegate.h"

#import "StandaloneCodeaViewController.h"

#import "GameCenterAddon.h"

#import "iAdsAddon.h"

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    //  Create and add our iAdsAddOn to Codea
    self.iAdsAddOn = [[iAdsAddon alloc] init];
    [self.viewController registerAddon: self.iAdsAddOn];
    NSString* projectPath = [[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:@"Killemann.codea"];

i didn’t change anything in the addon files…

i call showBannerFromTop in the setup() of main.lua

thx a lot for your help in advance!

Kind Regards,


I also tried to implement the audiaddon to play an mp3 file using play music() … but i get the same error: attempting to access a nil value (global play music)…

Where should I define the value of these addon functions? I thought they would be available by registering the functions using the addon files…?

any ideas anyone? (I’m pretty sure I’m just making a simple mistake…)

[duplicate post removed]

You don’t need an add on to play mp3s, you can use the built in music function

Hi, thx for the info. I figured it out and got both working anyway (as an addon like described in the tutorial). the mp3 plays fine now, and i also know why no ads are being displayed… IAds have been discontinued… :frowning:

if anyone needs a working Xcode project that contains this, let me know…

now i have to go and figure out how to add AdMob…

@jff2 I would actually like to see it, please, especially if you get the ads working. I have almost completed the app I’m working on, got just to add a few more screens. I want to make it free and make all my millions (dreaming high) with ads and IAP

Might be worth checking but I’m sure apple’s iAds have been discontinued.


You can still use another ad network.


@yojimbo2000 @Reefwing I’m talking to you guys specifically because I found this website,
I want to implement ads into my game and I know that I can’t use iAds because it was discontinued, and it may be more difficult because I’m using a third party ad network. I’ve read reefwing’s tutorials, and clearly he knows how to do the Objective-C stuff, and I’ve seen banjax from yojimbo, so can I have some help from anyone to help me implement ads into my game.
Thanks in advance

@jff2 @CamelCoder , hi brother. Hv u solved this? If done, is it possible to share your way and code here?

@totorofat I chose to use Chartboost

@totorofat I have gotten it to work, and I will post how to do it soon

@CamelCoder oh … it is so great…we are looking forward to seeing it.

appreciate in adv.

but iAd is canceled by app. which ad are you using? it is said that google admob is good. are you using that ?