用于iPhone测试的通用iPhone / iPad应用程序调试编译错误 [英] Universal iPhone/iPad application debug compilation error for iPhone testing

查看:90
本文介绍了用于iPhone测试的通用iPhone / iPad应用程序调试编译错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经编写了一个iPhone和iPad通用应用程序,可以在Xcode上的iPad模拟器中正常运行,但我现在想测试iPhone的功能。我似乎无法使用此代码运行iPhone模拟器,因为它始终默认为iPad?

I have written an iPhone and iPad universal app which runs fine in the iPad simulator on Xcode, but I would now like to test the iPhone functionality. I seem unable to run the iPhone simulator with this code as it always defaults to the iPad?

相反,我试图在设备上运行,因为它开始运行我得到以下错误:

Instead I tried to run on the device and as it begins to run I get the following error:

dyld: Symbol not found: _OBJC_CLASS_$_UISplitViewController
  Referenced from: /var/mobile/Applications/9770ACFA-0B88-41D4-AF56-77B66B324640/Test.app/Test
  Expected in: /System/Library/Frameworks/UIKit.framework/UIKit in /var/mobile/Applications/9770ACFA-0B88-41D4-AF56-77B66B324640/Test.app/TEST

由于应用程序是以编程方式构建的,而不是使用XIB,我使用main.m方法中的以下行拆分2设备逻辑:

As the App is built programmatically rather than using XIB's, I've split the 2 device logics using the following lines in the main.m method:

if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
    retVal = UIApplicationMain(argc, argv, nil, @"AppDelegate_Pad");
}
else
{
    retVal = UIApplicationMain(argc, argv, nil, @"AppDelegate_Phone");
}

从那时起他们使用不同的AppDelegates并且我已经检查了我的标题确保永远不会使用或通过电话逻辑导入UISplitView。

From that point forth they use different AppDelegates and I've checked my headers to ensure the UISplitView is never used nor imported via the Phone logic.

如何避免此错误,并且有更好的方法在此编程中拆分通用逻辑路径 - 创建了应用程序?

How do I avoid this error and is there a better way to split the universal logic paths in this programmatically-created app?

推荐答案

由于您没有弱化UIKit框架链接,因此触发了该错误。 iPhone OS 3.2中的UIKit框架添加了UISplitViewController,如果你正常链接它,你的应用程序将假设这些符号存在于3.0,而不是。

That error is being triggered because you didn't weak-link the UIKit framework. The UIKit framework in iPhone OS 3.2 added the UISplitViewController, and if you link it in as normal your application will assume those symbols exist on 3.0, where they don't.

要弱化链接框架,请在Xcode中找到您的应用程序目标,检查它,然后转到常规选项卡。该选项卡的底部应该是框架列表,其中包含Type列。将UIKit的类型从Required更改为Weak并重建您的应用程序。这应该处理运行时错误。

To weak-link a framework, find your application target in Xcode, inspect it, and go to the General tab. At the bottom of that tab should be a list of frameworks, with a column for Type. Change the Type for UIKit from Required to Weak and rebuild your application. That should take care of the runtime errors.

您的条件逻辑是合理的,但我倾向于共享一个应用程序委托,并进一步做特定于接口的布局。

Your conditional logic is sound, but I tend to share an application delegate and do the interface-specific layout further down the line.

(更新:12/21/2011)从iOS 4.2开始,您不再需要弱链接框架来防止这样的错误。正如 Marco Arment所描述的那样,如果您使用iOS 4.2或更高版本构建并定位到iPhone OS 3.1+,则各个类现在都是弱链接的,应该让它们的 + class 方法返回 nil 如果当前运行的操作系统版本中不存在该类。

(Update: 12/21/2011) As of iOS 4.2, you should no longer need to weak link frameworks to prevent errors like this. As Marco Arment describes, if you build with iOS 4.2 or later and target down to iPhone OS 3.1+, individual classes are now weak linked and should have their +class method return nil if the class does not exist on the currently running version of the OS.

这篇关于用于iPhone测试的通用iPhone / iPad应用程序调试编译错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆