Dilemma: iOS 4 or iPad-support?

Discussion in 'iOS Programming' started by Danneman101, Jul 4, 2010.

  1. Danneman101 macrumors 6502

    Aug 14, 2008
    Ive got an app that is not adapted to the iPad but will run on it just fine.

    I just finished updating the project to SDK 4, including an iAd etc.

    But since this update would not run on the iPad, replacing the existing one will reduce my customer-base.

    Im guessing most people who dont intend on making a hd-version for iPad have the same dilemma, so what have you done?

    Have you gone ahead and updated your app, hoping that the iOS 4 will soon hit the iPad and it will work there?

    Or have you uploaded a duplicate of you app, now distributing two apps?
  2. robbieduncan Moderator emeritus


    Jul 24, 2002
    Update Base SDK to 4.0. Set Target Deployment to 3.0. Use conditional coding techniques to only use 4.0 APIs on 4.0. That way you get iAds on 4.0 based devices and you can still use the same app on the iPad.
  3. Danneman101 thread starter macrumors 6502

    Aug 14, 2008
    To try this out I made a fresh project without any sdk 4-specific code, but as soon as I added the iAd-framework to the project it wouldnt run in the iPad simulator (immediately exited the app).

    So how do I make the inclusion of an entire framework conditional?

    And for that matter, how do a make a snippet of code conditional to the os running? How can I in code check the current os?
  4. robbieduncan Moderator emeritus


    Jul 24, 2002
    If your iAd view is in a nib then you may have remove it and do all of the iAd stuff in code (I don't know: I do all my UI in code).

    You will need to Weak Link the iAd framework (see the Apple documentation). Once you have done that you can conditionally use the symbols in the 4.0 SDK as described in the documentation (more here).
  5. broncopde macrumors 6502

    May 12, 2007
    Conway, AR
    Wirelessly posted (iPod touch: Mozilla/5.0 (iPod; U; CPU iPhone OS 3_1_3 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7E18 Safari/528.16)

    What is your app? That might help us think about this question with you.
  6. Danneman101 thread starter macrumors 6502

    Aug 14, 2008
    Thanks robbieduncan - I think I got it now :)

    For others having the same problem, here are the steps:

    1) In xcode, press "Targets" and set "iAd.framework"s (browse under "File Name") "Role" to "Weak".

    2) In your m-file, where you initialize your AdBannerView, surround that code with the following code (bold):

    [B]   Class classAdBannerView = NSClassFromString(@"ADBannerView");
        if (classAdBannerView != nil) {[/B]
    	if (!bannerIsVisible)
    		adView = [[ADBannerView alloc] initWithFrame:CGRectZero];
    		adView.frame = CGRectOffset(adView.frame, 0, 417);	// Dont show ad yet	
    		adView.requiredContentSizeIdentifiers = [NSSet setWithObject:ADBannerContentSizeIdentifier320x50];
    		adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifier320x50;
    		[self.view addSubview:adView];
    Apparently the first line tries to create an AdBannerView-class. If it works (ie youre running on ios 4 or later), the if-statement will take you further and set up the iad.

    Apparently I did not have to do anything to both the "didFailToReceiveAdWithError" and the "bannerViewDidLoadAd" functions. Just leave them as be.

Share This Page