Universal iPhone/iPad project with iAd framework

家住魔仙堡 提交于 2020-01-02 09:58:53

问题


how can I set up a Universal project which has support for iAd (just in the iPhone app)?

Using the iPhone SDK 4, let's suppose I do the following steps:

  1. Open XCode;
  2. Go to File > New Project ;
  3. Select Window-based application (or whatever), choose Product: Universal (and after choose a name for the project).

It will create a Universal project skeleton with iPhone/iPad groups as usual. Now, I decide to integrate iAd in my iPhone App, so I do the following:

  1. Right-click in the project's group called Frameworks > Add > Existing Frameworks...
  2. Choose iAd.framework > Add

So far, so good. I can simply Build And Run using the Active Executable as Project Name - iPhone Simulator 4.0 and the project runs OK. Suppose I change the Active Executable to Project Name - iPad Simulator 3.2. Although the iAd.framework is still being referenced in the Frameworks successfully (without being marked with the Red color), the App crashed in the iPad simulator and I get the following error message:

dyld: Library not loaded: /System/Library/Frameworks/iAd.framework/iAd Referenced from: /Users/nexia1/Library/Application Support/iPhone Simulator/3.2/Applications/8479EE14-28AA-4628-A668-CCF3FE770628/Untitled.app/Untitled Reason: image not found

Can I use the iAd in such a Universal project? (even that I only references it in my iPhone app).

Thanks in advance


回答1:


You need to weak link the framework, and in your code ask if the classes exist.

Apple has a similar example for this: http://developer.apple.com/iphone/library/samplecode/MailComposer/index.html

It is about the in-app mail sheet on 3.0 while still running on 2.x, but you'll get the point.



来源:https://stackoverflow.com/questions/3112016/universal-iphone-ipad-project-with-iad-framework

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