How do you optionally use iPhone OS 3.0 features i

2019-01-02 19:43发布

I'd like to use some features of iPhone OS 3.0 in my 2.0 app when it runs on a 3.0 device. I don't want to go 3.0 all the way because there are customers who do not want to update yet.

I experimented a bit with weak linking of the MapKit.framework (-weak_framework MapKit). I found it quite cumbersome, since I had to trick the compiler/linker to use the 2.0 SDK with all code except the one which uses MapKit.

Has anybody more experience with this? What are you doing to make it compile/link. Has anybody already submitted an app to Apple, which weak-links frameworks from other OS versions?

5条回答
骚的不知所云
2楼-- · 2019-01-02 20:14

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
查看更多
有味是清欢
3楼-- · 2019-01-02 20:16

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.

查看更多
浅入江南
4楼-- · 2019-01-02 20:23

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).

查看更多
怪性笑人.
5楼-- · 2019-01-02 20:31

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.

查看更多
牵手、夕阳
6楼-- · 2019-01-02 20:38

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.

查看更多
登录 后发表回答