How do you optionally use iPhone OS 3.0 features in a 2.0 compatible app?

若如初见. 提交于 2019-11-26 11:06:27

Apple has an example of how to do this, specifically making a 2.x-compatible app that uses MFMailComposeViewController....

http://developer.apple.com/iphone/library/samplecode/MailComposer/index.html

the answer involves compiling with the 3.0 SDK, setting the deployment target to 2.x, ensuring that the 3.0 frameworks are marked as "weak" references, and then doing the right thing to make your code work if you're on a device where the new frameworks aren't present.

You can always link to frameworks that are not part of the current SDK using the dlopen function. Of course, this is not recommended for frameworks that are not public (not recommended == forbidden on the app store, in this case). However, as new frameworks in unreleased versions of the OS become public, it's an option. Just check your version number, and open frameworks as available. Useful for individual features, not so much if you're making heavy use of new stuff.

This probably isn't the answer you're looking for, but the method I use is to just have two separate apps. Rather than updating my existing apps with 3.0 upgrades, I just release this as a new app. Old users can use the 2.0 app for as long as they want, and people that want the 3.0 features can upgrade.

Great howto on Weak Linking (both Libraries and Frameworks) here:

http://developer.apple.com/mac/library/documentation/MacOSX/Conceptual/BPFrameworks/Concepts/WeakLinking.html#//apple_ref/doc/uid/20002378-107262

Although it's a little out of date... with the latest x-code the process for weak linking an entire framework is actually easier:

  1. Right click the target and select Get Info
  2. Go to the "General" tab
  3. In the linked libraries section towards the bottom change the Type from required to weak for all libraries that you would like to weak link.
  4. Profit

I don't think you can. 3.0 and 2.x use completely different SDKs, and and link to a completely different set of files and libraries. I'm not certain, but I don't think you can link to the 3.0 SDK and still be 2.X compatible.

(please add a comment if I'm wrong).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!