Brian Coleman

  • Home
  • ABOUT
  • SERVICES
  • PORTFOLIO
  • BLOG
  • Contact

Ios 23

Framework: RevMob

fullscreen_ios
Generating revenue from free applications is difficult. One great way to do this, aside from In App Purchases, is advertising. Advertising not only helps to generate revenue directly, but it can also serve as a constant reminder for your users that they should upgrade to a paid version of your app. The annoyance should be just enough to get them to want to pay for your game, without disrupting their experience and making them hate your app. Learn more about advertising strategies in a previous post Monetize Your App: Ad Supported.

The advertiser that I use in my apps is called RevMob. RevMob provides full screen ads that show something like “DOWNLOAD A FREE GAME”. The generic, seemingly exciting message is supposed to win the users’ curiosity enough for them to click on the ad. When they download the app that is shown, you get paid in the range of $1-$3. RevMob is a fairly new platform but is growing fast. It’s getting rave reviews by developers that it has the highest eCPM in the ad industry.

Setting up the RevMob in Your App

Follow the steps below to get started with RevMob:

  1. Visit www.revmob.com and sign up, don’t worry it’s FREE!
  2. Click the “Apps” tab then “Add app” and Select the Platform your app is on (iOS App).
  3. Enter the Name of your application.
  4. Make sure you copy the unique application ID (APP ID), you’re going to need it soon.
  5. Download the latest RevMob iOS SDK.
  6. Drag and drop the directory RevMobAds.framework inside one file group of your project on XCode (usually, “Frameworks”).
  7. Be sure to include the frameworks SystemConfiguration.framework, StoreKit.framework and AdSupport.framework that are not included by default. You can do that by clicking in the project root > Build Phases > Link Binary With Libraries > Click in the + button.
  8. Add the following code into your App Delegate.
    #import 
    - (void)applicationDidFinishLaunching:(UIApplication *)application 
    {
         [RevMobAds startSessionWithAppID:@"copy your RevMob App ID here"];
         //your code
    }
    

    The code above initializes the RevMob framework in your app. Be sure you add the correct APP ID for the application you setup on the RevMob website. Don’t put in the specific ad unit ID. The only ID you ever need to input is the APP ID, all of the banners will be called using the default methods that don’t require IDs.

  9. Insert a Full Screen ad within your application
    #import 
    - (void) displayAd {
         [[RevMobAds session] showFullscreen];
    }
    

    Above you’ll see the basic implementation for adding a Full Screen ad to your app. Be sure to include the RevMob framework at the top of the View Controller you are inserting the ad into. As another example see how to insert a Banner ad using the code below.

  10. Insert a Banner ad within your application
    #import 
    - (void) displayAd {
         [[RevMobAds session] showBanner];
    }
    

There are a couple of other ad units available such as Links, Buttons and Popups. You can read more information about integrating these in the RevMob SDK Documentation.

RevMob is one of the easiest SDKs to integrate into your app, so why not do it and start making money!

July 24, 2013 Frameworksframework, ios, tutorial

Tutorial: Using Sub-Projects & Git Submodules to Create a Framework in iOS

If you manage a number of iOS applications that have a lot of the same features you may want to consider building a framework that can be used across all of them. There are a couple ways to do this, the most common would be to build a static library.

A great solution for creating a living framework that is worked on my multiple people is to create a sub-project. This means that we’ll store all of the re-useable code in the sub-project and embed it into the projects for all of our apps. This works especially well if you are using GitHub across all of your apps. I’ll show you how to add the sub-project as a submodule in Git allowing the sub-project to be modified as often as possible, then when you have to update your project with the most recent fixes you just pull the latest code from the sub-project and your master project is automatically updated.

Create the Static Library Project

To start we need to build the sub-project that will contain all the reusable code for our Framework. Create a new project from the “Cocoa Touch Static Library” template as shown in the screenshots below.

Static Library 1

Screen Shot 2013-07-05 at 9.08.05 AM

When saving your project, ensure that the “Create local git repository for this project” is checked, we’ll need this later when we want to automatically update our parent project with the latest code from the framework project using Git submodules.

Screen Shot 2013-07-05 at 9.08.39 AM

Next you’ll need to modify the copy files section within the target Build Phase so the library can be accessed by the project that includes it. Remove “${PRODUCT_NAME}” from the Subpath so only “include” remains.

Screen Shot 2013-07-05 at 9.09.22 AM

We’ll need to add all of the assets within the Framework into a Resource Bundle. Normally all of your assets are stored in the projects “main bundle” but for another project to access the assets using a library the best way is to store them in their own bundle. Resource Bundles should store all your images and nibs (XIB). Add a target to the library project using the template “Bundle”. From the “Build Settings” of your library project click the “Add Target” button.

Screen Shot 2013-07-05 at 9.09.48 AM

After the Resource Bundle is added we need to fix it’s architecture properties because by default Xcode adds it as a Mac OS X architecture. Navigate to the “Build Settings” of the Resource Bundle and change the “Base SDK” to the “Latest iOS” option.

Screen Shot 2013-07-05 at 9.10.50 AM

Below I’m adding a new UIViewController named “AdViewController”. This is going to be added to the Framework project and later we’ll access this class within the parent project. This will show you that you can add any class / SDK you wish to your Framework allowing you to access or extend it within your parent project. First we’ll create a new Objective-C class which will be a subclass of UIViewController.

Screen Shot 2013-07-05 at 9.11.15 AM

Screen Shot 2013-07-05 at 9.11.26 AM

Ensure that the new class is only being added to the “MyFramework” target, not the bundle. We’ll add the nib (XIB) to the Resource Bundle separately, we don’t want our .h or .m files in the Resource Bundle since it doesn’t know how to handle them when compiled.

Screen Shot 2013-07-05 at 9.11.37 AM

Navigate to the new “AdViewController.xib” file and check “MyFrameworkBundle” under the “Target Membership” on the right.

Screen Shot 2013-07-05 at 9.12.04 AM

Next we want to add our objects to the nib (XIB). Drag in a UILabel and change it’s text to “Hello Ad Framework”.

Screen Shot 2013-07-05 at 9.13.02 AM

Go to the “Build Phases” section and add the “AdViewController.xib” to the “Copy Bundle Resources” and in “MyFramework” add “AdViewController.h” to the Copy Files to ensure that these files will be accessible to the parent project.

Screen Shot 2013-07-05 at 9.13.34 AM

Screen Shot 2013-07-05 at 9.15.13 AM

Lastly commit all of the changes we’ve made to Git. Select “File > Source Control > Commit…”.

Screen Shot 2013-07-05 at 9.22.56 AM

That’s it our static library Framework is complete. Next let’s look how to incorporate this framework into an everyday project.

Create the Parent Project

You may already have an existing project to add your new Framework into but we’re going to assume that you’re starting a whole new project and the first thing you are going to do is add your Framework that contains all of the reusable classes you’ll use in your new app. Start out by creating a new “Single View Application”.

Screen Shot 2013-07-05 at 9.33.06 AM

Screen Shot 2013-07-05 at 9.33.21 AM

Same as with the static library, ensure that the “Create local git repository for this project” is checked, we need it to be able to add the Framework as a submodule.

Screen Shot 2013-07-05 at 9.33.29 AM

Let’s add the Framework as a Git submodule. Since we’re adding it as a submodule, anytime that the Framework has been updated all you’ll need to do it do a “git pull” from the submodule and your parent project and any other projects will be all be up to date without having to go into each one and cut and paste all the changes. So if you have 10 apps that all use your Framework and you fixed a bug with the Ad class or needed to update the latest third party SDK you use, make the change in your Framework, then open each of your apps, pull the latest Framework code, recompile and you’re ready to release your update to the App Store.

Navigate to the directory of your parent product using Terminal and type “git submodule add ../MyFramework” and press enter. This assumes that your Framework is stored locally. If you are using GitHub or BitBucket, point to the address of your repository.

Screen Shot 2013-07-05 at 9.34.38 AM

The Framework project will be added to a sub-directory under your parent project folder. Next, drag the Framework project file (.xcodeproj) into your parent product dock, as shown below.

Screen Shot 2013-07-05 at 9.35.57 AM

Screen Shot 2013-07-05 at 9.36.25 AM

Edit the parent project scheme to make it build the Framework’s project targets first. Edit the scheme and under the “Build” tab click the plus at the bottom and add the library target and library resources target. Select all of the Frameworks Targets and click “OK”.

Screen Shot 2013-07-05 at 9.36.35 AM

Screen Shot 2013-07-05 at 9.36.41 AM

Screen Shot 2013-07-05 at 9.36.45 AM

Link your Framework library file to your parent project. This is done very similar to how to include Frameworks like the “AudioToolbox.framework”. Select your parent project target, and click the + button under the “Linked Frameworks and Libraries” section, then choose the .a file associated with your Framework.

Screen Shot 2013-07-05 at 9.37.14 AM

To include the Resource Bundle, expand the “Products” folder from the Framework and drag the “MyFrameworkBundle.Bundle” into the “Copy Bundle Resources” section under the parent project target. Don’t mind that the colour of the two files under the products folder are red, they will look normal once they are compiled.

Screen Shot 2013-07-05 at 9.37.39 AM

Add the Framework targets into the “Target Dependencies” of the parent project so they will be compiled first before your parent product is compiled. If this isn’t done your project won’t know where to find the classes you are referencing.

Screen Shot 2013-07-05 at 9.38.14 AM

Screen Shot 2013-07-05 at 9.38.18 AM

Update the header search paths of the parent project. Go to “Build Settings” of the project and look for “User Header Search Paths”. Then set the target setting to “$(BUILT_PRODUCTS_DIR)” and select “Recursive”. This will be the location where your parent project will pickup the headers (.h) files of the Framework.

Screen Shot 2013-07-05 at 9.38.53 AM

Using The Framework

We’ve integrated the Framework into our parent project, now we’re ready to use the classes within it. This should be very straightforward because we can leverage the classes just like you would from within your project.

First import the header at the top of your implementation file.
[syntax_prettify linenums=””]
#import “AdViewController.h”
[/syntax_prettify]

Then add the following code to leverage the Framework Resources Bundle and present the AdViewController within the app.
[syntax_prettify linenums=””]
NSBundle *bundle = [NSBundle bundleWithURL:[[NSBundle mainBundle] URLForResource:@”MyFrameworkResources” withExtension:@”bundle”]];
AdViewController *adView = [[AdViewController alloc] initWithNibName:@”AdViewController” bundle:bundle];
[self.view addSubview:adView.view];
[/syntax_prettify]

Once completed your code should look like this.

Screen Shot 2013-07-05 at 9.40.12 AM

When you run the sample project, the output should show the AdViewController.

Screen Shot 2013-07-05 at 9.40.37 AM

I hope this tutorial helped you to create your own Framework. Remember the advantage of embedding it as a sub-project allows you to view the code for the Framework while you’re using it and adding it as a Git submodule makes it really easy to keep your parent products up to date with the latest code for the Framework. Now go create your own Framework with all of the amazing classes you have created and want to reuse in every new app you create.

Grab the Source Code to this tutorial to help you debug any issues you had, but try to follow the tutorial yourself so you can learn all of the steps to ensure you know what each one does.

July 10, 2013 Tutorialsframework, ios, objective-c, tutorial

Tutorial: Run a Block of Code After a Delay

LED Baseball Pitch
For the longest time I’ve wanted to know how to pause the app or wait a certain amount of time before running a block of code. This is often useful for when you’re doing simple animations or if you need to wait before updating the UI. Take the example to the right, in the LED Baseball game I needed to find a way to animate the pitches from the mound to home plate. The LEDs images are in set spots, and for the effect of a pitch they need to blink on and off in sequence, sometimes at different speeds depending on the pitch.

The best way to implement this code block is to implement a category that can be reused in any of your projects.
The following code is credited to Duncan C.

The header file: (filename = NSObject+performBlockAfterDelay.h)

//
//  NSObject+performBlockAfterDelay.h
//
//  Copyright (c) 2012 WareTo. May be used by anyone, free of license, as 
//  long as this copyright notice remains.
//

@interface NSObject (performBlockAfterDelay)

- (void) performBlock: (dispatch_block_t) block
           afterDelay: (NSTimeInterval) delay;

@end

The .m file: (filename = NSObject+performBlockAfterDelay.m)

//
//  NSObject+performBlockAfterDelay.m
//  ChromaKey
//
//  Copyright (c) 2012 WareTo. May be used by anyone, free of license, as 
//  long as this copyright notice remains.
//

#import "NSObject+performBlockAfterDelay.h"

@implementation NSObject (performBlockAfterDelay)

- (void) performBlock: (dispatch_block_t) block
           afterDelay: (NSTimeInterval) delay;
{
  dispatch_after(dispatch_time(DISPATCH_TIME_NOW, delay * NSEC_PER_SEC), dispatch_get_current_queue(), 
                 block);
}
@end

To use it, just add the .m and .h files above to your project.
Then add a #import at the top of any .m file that needs this method:

#import "NSObject+performBlockAfterDelay.h"

Here’s a sample of the code in action for a fastball in LED Baseball.

[self performBlock:^{led1.hidden = NO;} afterDelay: .75];
[self performBlock:^{led1.hidden = YES;led2.hidden = NO;} afterDelay: .15];
[self performBlock:^{led2.hidden = YES;led3.hidden = NO;} afterDelay: .225];
[self performBlock:^{led3.hidden = YES;led4.hidden = NO;} afterDelay: .3];
[self performBlock:^{led4.hidden = YES;led7.hidden = NO;} afterDelay: .375];
[self performBlock:^{led7.hidden = YES;led8.hidden = NO;} afterDelay: .45];
[self performBlock:^{led8.hidden = YES;led9.hidden = NO;} afterDelay: .525];

By running a series of blocks in a row, each LED is shown, then hidden after a set delay.

I hope this code helps you as much as it did me, I’ll be using this category anytime I need to “pause”.

June 26, 2013 Tutorialsios, objective-c, tutorial

Tutorial: Write a Review / Rate Us

User ratings play a huge role in where your app ranks on Apples Top Charts lists, and it influences new users who are considering downloading your app. Yet it’s often tough to get users to rate your app, because without reminding them and making it really simple they most likely will not review your app. The only exception to this is the user who only wants to criticize your app or the die hard fans of the app. The largest user segmentation you have is the users who like your app and these users are the ones we need to remind.

There is also a problem of misuse in regards to ratings. Often users who don’t know better will use the review along with a low rating in an attempt to get tech support from a developer. This is flawed for everyone involved; it lowers the rating of the app, scares away new users, and worst of all, as a developer we have no way to get in touch with users who rate our app.

Below is the code that belongs in your – (void)viewDidLoad or – (void)viewWillAppear methods. It checks to see how many times the user has launched the app and increments it by 1. If the launch counter is equal to 3, 9, 15, or 21 we’ll show the Rate App alert message unless “neverRate” equals to YES.

    NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
    //Ask for Rating
    BOOL neverRate = [prefs boolForKey:@"neverRate"];

    int launchCount = 0;
    //Get the number of launches
    launchCount = [prefs integerForKey:@"launchCount"];
    launchCount++;
    [[NSUserDefaults standardUserDefaults] setInteger:launchCount forKey:@"launchCount"];
    
    if (!neverRate)
    {
        if ( (launchCount == 3) || (launchCount == 9) || (launchCount == 15) || (launchCount == 21) )
        {
            [self rateApp];
        }
    }
    [prefs synchronize];

When we ask the user if they would like to rate the app it’s good to give them three options “Rate It Now”, “Remind Me Later” and “No, Thanks”. If the user selects one of the first or last then we’ll set NSUserDefaults to YES so the user will never see the alert again. If they select “Maybe Later” we’ll show it to them again in the future.

- (void)rateApp {   
    BOOL neverRate = [[NSUserDefaults standardUserDefaults] boolForKey:@"neverRate"];
    
    if (neverRate != YES) {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Please rate !"
                                                        message:@"If you like it we'd like to know."
                                                       delegate:self
                                              cancelButtonTitle:nil
                                              otherButtonTitles:@"Rate It Now", @"Remind Me Later", @"No, Thanks", nil];
        alert.delegate = self;
        [alert show];
    }
}

- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
{
    if (buttonIndex == 0) {
        [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"neverRate"];
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=573753324"]]];
    }
    
    else if (buttonIndex == 1) {
        
    }

    else if (buttonIndex == 2) {
        [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"neverRate"];
    }
}

If the user selects “Rate” they will be redirected to your app within the App Store, and the Rates & Reviews section already opened. To make it go to your app, change “573753324” in the code above to point to your unique app id within iTunes Connect. If you leave it as is your users will be directed to my Travel Bomb app, I could use some reviews!
how_many_reviews_do_ios_developers_have

May 29, 2013 Tutorialsios, objective-c, tutorial

Tutorial: Export Adobe Flash as an iOS App

Are you a rock star Flash Developer but don’t want to learn Objective-C to release apps to the App Store? Maybe you’ve heard “It’s not possible to run Flash on iOS”. It’s all possible with Adobe Flash CS5!

The workflow is pretty simple. You take your Flash game, modify it a little bit to fit the screen resolution and touch input of your mobile device and export that exact game to iOS with just one single click. You will create your iOS app from within the Flash workspace using the same familiar tools. You can code ActionScript and use the built-in code snippets. There a several new code snippets added specifically for mobile devices. Flash has some new built-in ActionScript to deal with the mobile Accelerometer and touch events that have made the user experience with tablet devices so very popular.

Below are a couple of useful tutorials to show you how to setup your Flash project so you can export directly to iOS.

Creating iOS Apps Using Flash

Learn how to setup your Flash project settings. Note that the iOS export only supports ActionScript 3.0. Make sure you change the stage size to “960×640” pixels for iPhone 4, and “2048×1536” pixels for iPad so it works with the the latest retina display.

Creating a Distribution Provisioning Profile

In order for you to be able to submit apps to the Apple App Store you first need to register as a developer in the iOS Dev Center and pay a $99/year fee. If you want to launch an app on a device that requires a development provisioning profile, install the provisioning profile on the device. In Member Center, you can register individual devices as needed or multiple devices by uploading a file that contains information about each device.

Deploying to an iOS Device

After setting up the developer certificates and provisioning profiles in the Apple Developer Center and setting up the project with the proper settings, it should only take a couple of hours to get your app running on the iPad. Almost no code changes are necessary.

Apple Dev Centre

With this method, Flash will export your app as an IPA file which can be submitted to the App Store, it will not export your code into Objective-C. Therefore you will not be able to modify the app or add in-app purchases or enhanced native features. If you have a great Flash game that’s already done, this is the best way to export it, upload it to iTunes Connect and start making money in the App Store.

April 25, 2013 Tutorialsios, tutorial
Page 2 of 5«12345»
Recent Posts
  • Classix for iPhone, iPad & Apple TV
  • Tutorial: How to test your app for IPv6 compatibility
  • Tutorial: Testing SSL using Charles Proxy on an iOS Device
  • Tutorial: 3D Touch – Quick Actions in Swift
  • tvOS Tutorial: Top Shelf in Swift
Featured Apps
Classix
Sportsnet
TAGS
tutorialswiftios8iosobjective-cvideogamesstrategynewsframeworkappsmonitizefacebookwatchappleios7toolstvosios9apiprovisionsocialtutorialsbooksdesignbookiapIPv6iTunes Connect
Search
TAGS
tutorialswiftios8iosobjective-cvideogamesstrategynewsframeworkappsmonitizefacebookwatchappleios7toolstvosios9apiprovisionsocialtutorialsbooksdesignbookiapIPv6iTunes Connect
ABOUT
Brian is a Lead iOS/tvOS Developer from Toronto with over 18 years of multifaceted experience including development, design, business analysis and project management.

FOLLOW ME
    
Email Subscription
Sign up for my newsletter to receive the latest news and tutorials posted.

Enter your email address:

2023 © Brian Coleman