简体   繁体   English

如何在Xcode 3.2.3(iPhone SDK 4 beta)中启动iPhone 3.1.3项目

[英]How to start an iPhone 3.1.3 project in Xcode 3.2.3 (iPhone SDK 4 beta)

I am having big problems since I downloaded the beta version of iPhone SDK 4.0. 自从我下载iPhone SDK 4.0的测试版以来,我遇到了很大的问题。 Okay, I just started to look at iPhone development a few weeks ago, but I cannot figure out how Xcode is supposed to work: 好吧,几周前我刚刚开始关注iPhone开发,但我无法弄清楚Xcode应该如何工作:

whenever I start a new project, I choose a template like "View-based application" or so. 每当我开始一个新项目时,我都会选择像“基于视图的应用程序”这样的模板。 Now, the target will always (at least I did not find a preference anywhere!) be the latest SDK: 4.0. 现在,目标总是(至少我没有在任何地方找到偏好!)是最新的SDK:4.0。 But then: switching the target back to, say, 3.1.3 the template files seem to contain errors! 但是:然后:将目标切换回3.1.3,模板文件似乎包含错误! Starting an empty application this way yields an exception: 以这种方式启动空应用程序会产生异常:

Terminating app due to uncaught exception 'NSUnknownKeyException', reason: [...] this class is not key value coding-compliant for the key rootViewController 因未捕获的异常'NSUnknownKeyException'而终止应用程序,原因:[...]此类不是键值rootViewController的键值编码兼容

Reason, it seems, is that the generated MainWindow.xib has a "referencing outlet" for rootViewController next to a viewController... 看来,原因是生成的MainWindow.xib在viewController旁边有一个rootViewController的“引用插座”...

sick 生病

Now, my (stupid) question: How do I develop an application NOT targeting the latest SDK, but the standard 3.1.3 SDK?? 现在,我的(愚蠢)问题:我如何开发一个针对最新SDK的应用程序,而是标准的3.1.3 SDK? In other words: I would expect Xcode not only to ask for a project type in the New Project window, but also for my desired target platform to generate the correct templates!! 换句话说:我希望Xcode不仅要在New Project窗口中询问项目类型 ,还要为我想要的目标平台生成正确的模板!

Am I right that the templates generated with this step are not valid for any other target than 4.0? 我是否正确使用此步骤生成的模板对4.0以外的任何其他目标无效? How can that be?? 怎么可能??

...I want my Eclipse back! ......我想要我的Eclipse回来! sigh

Can anybody help me please? 有人能帮帮我吗?

Just in case someone is looking for this. 以防万一有人在寻找这个。

Just check if the window responds to the function first. 只需检查窗口是否首先响应该功能。 If it does (4.0 and greater), then use it, otherwise use the pre 4.0 version first. 如果是(4.0及更高版本),则使用它,否则首先使用pre 4.0版本。

if([self.window respondsToSelector:@selector(rootViewController)]) {
    self.window.rootViewController = self.viewController;        
} else {
    [self.window addSubview :self.viewController.view];        
}

Simple: don't use the beta SDK, which is intended at this stage for developing apps for an unreleased version of the OS, and about which you have agreed to a NDA. 简单:不要使用beta SDK,它在此阶段用于为未发布的操作系统版本开发应用程序,以及您已同意NDA的应用程序。

So download the released version of the SDK, and be happy. 所以下载SDK的发布版本,并开心。

The resolution I found was to manually add my View to the Window in didFinishLaunchingWithOptions instead of relying on the Interface Builder connection. 我发现的解决方案是在didFinishLaunchingWithOptions中手动将我的View添加到窗口,而不是依赖于Interface Builder连接。 It seems that wiring up rootViewController w/iOS4 IB causes the app to crash when deployed to 3.x (3.1.3 for me). 似乎连接rootViewController w / iOS4 IB导致应用程序在部署到3.x时崩溃(3.1.3对我来说)。

So, first open IB, right click on Window, and make sure "rootViewController" isn't connected. 因此,首先打开IB,右键单击Window,并确保“rootViewController”未连接。 Then in your AppDelegate, you should have something like 然后在你的AppDelegate中,你应该有类似的东西

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [self.window addSubview:navigationController.view];
    [self.window makeKeyAndVisible];

    return YES;
}

This is for if your main view is a navigationController; 这适用于主视图是navigationController的情况。 if it's not, change addSubview accordingly. 如果不是,请相应地更改addSubview。

The answer to the question I was looking for seems to be: 我正在寻找的问题的答案似乎是:

It is not possible. 这不可能。

To develop for a certain iOS release, install the appropriate Xcode. 要开发某个iOS版本,请安装相应的Xcode。 Apple apparently does not know people who want to develop for multiple target platforms at once. Apple显然不知道想要同时为多个目标平台开发的人。 :-( :-(

I think Francois has a great answer. 我认为弗朗索瓦有一个很好的答案。

I am also new to Xcode and was working through various tutorials using Xcode 3.2.6 and testing on iOS 3.1.3 device. 我也是Xcode的新手,正在使用Xcode 3.2.6并在iOS 3.1.3设备上进行测试。 The tutorials were for iOS 4.3, which all start by selecting a "View-based application." 这些教程适用于iOS 4.3,所有这些都是从选择“基于视图的应用程序”开始的。 When I tested the tutorials they worked in the simulator but not on the device. 当我测试教程时,他们在模拟器中工作但不在设备上工作。 I assume this is true for SDK 4 but I haven't tried it myself. 我认为这适用于SDK 4,但我自己没有尝试过。

I first received the error:"...specifies a minimum OS version of 4.3, which is too high to be installed on iPhone." 我第一次收到错误:“...指定最低操作系统版本为4.3,这个版本太高而无法在iPhone上安装。”

Many other people have addressed this but it is fixed by going to Project>Edit Project Settings, selecting the Build tab, scrolling down to the Deployment section and changing the field "Development Target iOS" to be the same as the iOS on the device. 许多其他人已经解决了这个问题,但是通过转到项目>编辑项目设置,选择构建选项卡,向下滚动到部署部分并将“开发目标iOS”字段更改为与设备上的iOS相同,可以解决此问题。

Then the tutorial apps would launch on the phone but only a blank screen would show and I got the error: “SIGABRT” and "NSException" - even when I just tried to launch a simple HelloWorld app. 然后教程应用程序将在手机上启动,但只显示一个空白屏幕,我收到错误:“SIGABRT”和“NSException” - 即使我只是尝试启动一个简单的HelloWorld应用程序。 This was caused by the self.window.rootViewController = self.viewController not being supported by iOS 3. 这是由iOS 3不支持self.window.rootViewController = self.viewController引起的。

To fix it go to the ___Delegate.m file and replace the line "self.window.rootViewController = self.viewController" with Francois' elegant solution: 要修复它,请转到___ Delegate.m文件,并用Francois优雅的解决方案替换“self.window.rootViewController = self.viewController”行:

 if([self.window respondsToSelector:@selector(rootViewController)]) {
    self.window.rootViewController = self.viewController;        
} else {
    [self.window addSubview :self.viewController.view];        
}

Now the View-based application template in SDK 3.2 works for iOS 3 and 4. 现在,SDK 3.2中基于视图的应用程序模板适用于iOS 3和4。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM