Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Danneman101

macrumors 6502
Original poster
Aug 14, 2008
361
1
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?
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
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.
 

Danneman101

macrumors 6502
Original poster
Aug 14, 2008
361
1
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.

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?
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
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).
 

broncopde

macrumors 6502
May 12, 2007
262
1
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.
 

Danneman101

macrumors 6502
Original poster
Aug 14, 2008
361
1
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):

Code:
[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];
		adView.delegate=self;
	}	 
[B]}[/B]

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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.