With iOS 4 comes 1500 new features for developers to take advantage of. Unfortunately, not all of your users will be able to enjoy this new experience. For example, if your user has a 1st generation device only capable of running OS 3.1. Or an iPad which (at the time of writing this article) only runs 3.2. Utilizing some of these new features will make or break a cross version app, but some can be worked with. This tutorial demonstrates how to solve this problem.
Let’s use iAds as an example. Apple announced that iAds will only available on iOS 4 which at the moment leaves the iPad, iPhone 1G, and iPod Touch 1G users unable to use an app with iAds unless you change a few things in your build. Simply adding the iAd framework to your project will break a 3.1 build. But there is a way around it all allowing you to deploy to practically everybody except those refusing to move on from iPhone OS 2.x. The solution is weak linking your frameworks, and here is how to do it.
In Xcode, expand your targets and right click (or ctrl-click) on your target. Select “Get Info” from the popup menu.
Under the “General” tab, find the iOS 4 framework you would like to weak link and click “Required.” In the popup menu that appears, select “Weak” and close the window, recompile, run, voila!
Random Posts:
- iStrobe 25th Most Downloaded Utility
- iOS 4.1 seeded to developers
- iPhone Game Proof of Concept
- BASIC Compiler Open Sourced!
- “The binary you uploaded was invalid…”
If you found this useful, shoot me a small donation or at the very least leave a comment, every bit of encouragement helps keep me motivated to update with more content on a regular basis!
Tags: Development, framework, iad, iads, ios, iPhone, link, Objective-C, programming, tutorial, weak, Xcode
You can skip to the end and leave a response. Pinging is currently not allowed.


[...] here to read the rest: Using iOS 4 Frameworks on OS 3 « iPhone Open Source – Nick Vellios Filed Under Open Source, Uncategorized Tagged With code-snippets, Open Source [...]
[...] Using iOS 4 Frameworks on OS 3 « iPhone Open Source – Nick Vellios [...]
Excellent to-the-point writeup! I never thought this would even be possible. Love your blog, keep the informative posts coming! Please!
[...] This post was mentioned on Twitter by Nick Vellios, Nick Vellios. Nick Vellios said: Develop apps using iOS 4 frameworks on iPhone OS 3 http://bit.ly/9qOc08 [...]
Great article! What happens when iOS 3 tries to call up one of these frameworks? Do you have to change your code to handle error messages?
Marcus, my understanding is that in most cases a message is simply sent with no listener to receive it. Of course all frameworks will be different and you should read Apple’s documentation in detail for what you intend to implement. Be sure to thoroughly test your code on older devices.
You may need to add some code to do different things for different versions of the OS. In the latest version of SpaceBubble I implemented iAd. I use the following code to create my iAd view:
Class cAddBannerView = NSClassFromString(@"ADBannerView"); if (cAddBannerView != nil) { // Setup adbanner view }And later in the code I check to see if my adbanner view is nil or not. If it is not nil, I need to move a few controls around to make room for the ad. Hope this makes sense.
Thanks for this post – it enabled me to solve a crash bug very quickly! Didn’t know how to weak link to frameworks, but it’s just what I needed to do.