开发者

Universal iPhone/iPad project with iAd framework

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 m开发者_运维百科arked 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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜