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

查看:21
本文介绍了用于 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 的类型从必需更改为弱并重建您的应用程序.这应该处理运行时错误.

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天全站免登陆