问题
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:
- Open XCode;
- Go to File > New Project ;
- 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:
- Right-click in the project's group called Frameworks > Add > Existing Frameworks...
- 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