使用Xcode 4.3.x构建适用于iOS 3.0的通用应用程序 - NSKeyedUnarchiver例外 [英] Build universal app for iOS 3.0 using Xcode 4.3.x - NSKeyedUnarchiver Exception

查看:202
本文介绍了使用Xcode 4.3.x构建适用于iOS 3.0的通用应用程序 - NSKeyedUnarchiver例外的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试使用Xcode 4.3.2构建和调试适用于iOS 3.0的通用应用程序。我从NSKeyedUnarchiver获得了一个NSException。它似乎可能与无法读取主.xib文件有关。我已经看到了这一点: iOS和unarchiving xib文件 - 但是,在这种情况下它是不清楚应用程序是通用的(他们的解决方案不起作用)(注意:他们的解决方案不起作用,因为他们使用Xcode 4.2,而不是4.3)。

Trying to build and debug a universal app for iOS 3.0 using Xcode 4.3.2. I'm getting a NSException from NSKeyedUnarchiver. It seems it may be related to inability to read the main .xib file. I have seen this: iOS and unarchiving xib files -- however, in that case it's not clear the app is Universal (their solution doesn't work) (NOTE: Their solution doesn't work because they're using Xcode 4.2, not 4.3).

这是错误输出:

2000-01-01 11:00:39.-19 myApp[664:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSKeyedUnarchiver initForReadingWithData:]: incomprehensible archive (0x4e, 0x49, 0x42, 0x41, 0x72, 0x63, 0x68, 0x69)'
2000-01-01 11:00:39.-01 myApp[664:207] Stack: (
        808001701,
        805397928,
        807551015,
        807550919,
        810902709,
        815043196,
        815042704,
        814682908,
        814682012,
        814970032,
        814968048,
        814966908,
        839149932,
        807750263,
        807747947,
        814678868,
        814672532,
        12253,
        12124
    )
    terminate called after throwing an instance of 'NSException'
    Not safe to look up objc runtime data. 


推荐答案

我想我会与NSKeyedUnarchiver分享我的解决方案难以理解的档案xib错误。

Just thought I'd share my solution to this NSKeyedUnarchiver incomprehensible archive xib error.

我刚刚花了几个星期把头发拉出来,我的解决方法与上面的borrrden几乎相同(即使用构建的nib文件)旧版Xcode)。我尝试了一切我能想到的没有任何快乐的事情。 (我的其他选择是停止使用xib文件并在代码中编写整个UI或停止支持iOS 3.0)

I've just spent a couple of weeks pulling my hair out on this, and my workaround is pretty much the same as borrrden's, above (i.e. use nib files built with an old version of Xcode). I tried everything else I could think of without any joy. (My other choices were to stop using xib file and write the entire UI in code or to stop supporting iOS 3.0)

所以,这是我的情况,我是怎么得到的工作的解决方法以及我如何为应用商店构建分发存档。

So, here is my situation, how I got the workaround to work and how I went about building a Distribution Archive for the app store.

首先是一点点背景:我的应用最初是使用Xcode 3.2.5构建,在iOS 3.0及更高版本上运行良好。当我升级到Xcode 4.2时,只要应用程序加载了一个xib文件,我就会收到NSKeyedUnarchiver错误。经过一段谷歌搜索后,我遇到了这个帖子中提到的其他文章,所以我改变了每个xib文件的部署和开发版本。这是一种享受,直到我在错误返回时升级到Xcode 4.3.1。我重新检查了所有的xib文件,但没有快乐。即使它们设置为iOS3.0 / IB3.0(并且我尝试了所有组合),该应用程序仍然崩溃。

First a wee bit of background: My app was originally built with Xcode 3.2.5 and worked fine on iOS 3.0 and above. When I upgraded to Xcode 4.2 I got the NSKeyedUnarchiver error as soon as the app loaded a xib file. After a bit of Googling I came across the other articles mentioned in this thread, so I changed the Deployment and Development versioning on each xib file. This worked a treat, until I upgraded to Xcode 4.3.1 when the error returned. I re-checked all the xib files but no joy. Even though they were set for iOS3.0/IB3.0 (and I tried every combination available), the app still crashed.

试图证明这是一个我尝试在设备上调试的xib文件的问题(运行iOS 3.0的第二代iPod Touch,通过电缆连接到Xcode)。但是在调试器开始运行之前,应用程序会崩溃。所以我从项目中删除了MainWindow.xib(在代码中设置了App Delegate和UIWindow)。这允许调试器启动并点击我的第一个断点(第一行应用程序:didFinishLaunchingWithOptions),但是只要我推动ViewController,app就会挂起而不会抛出异常。经过大量挖掘后,我将调试器从LLDB切换到GDB(从产品 - >编辑方案)。这阻止了应用程序挂起并按照我的预期抛出异常(难以理解的存档)。 LLDB显然仍然存在问题。

In an attempt to prove this was a problem with the xib files I tried debugging on device (a 2nd generation iPod Touch running iOS 3.0, attached to Xcode by cable). But the app would crash before the debugger could get going. So I removed MainWindow.xib from the project (setting the App Delegate and UIWindow up in code). This allowed the debugger to get started and hit my first breakpoint (the first line of application:didFinishLaunchingWithOptions), but the app would just hang without throwing an exception as soon I pushed a ViewController. After much digging I switched the debugger from LLDB to GDB (from Products -> Edit Scheme). This stopped the app from hanging and threw the exception as I expected it should (the incomprehensible archive one). LLDB obviously still has issues.

经过几周的努力,我唯一能做的就是使用旧版Xcode构建的nib文件。幸运的是我仍然在我的机器上安装了Xcode 3.2.5。以下是我使用此步骤的步骤,并允许为应用商店构建存档:

After a couple of weeks of pulling my hair out the only thing that worked was to use nib files built with an old version of Xcode. Luckily I still have Xcode 3.2.5 sitting on my machine. Here are the steps I used to get this working, and to allow an Archive to be built for the app store:


  • 退出Xcode 4.3。 1并启动Xcode 3.2.5。

  • 创建一个新的基于View的应用程序项目,并将主项目中的所有.xib文件添加到其中。

  • 将部署目标设置为iOS3.0,然后在设备上执行发布构建和运行(如果它不自动选择,请使用您的通用配置文件)

  • 来自Xcode,显示查找包中的.app,然后显示包内容以查看其中的所有.nib文件(Xcode已将.xib文件转换为.nib文件)。

  • 为方便使用,请复制.nib文件到另一个目录。

  • 退出Xcode 3.2.5并启动Xcode 4.3.1并打开你的项目。

  • 访问每个xib和从右侧边栏中取消选择目标成员资格中的应用程序(这意味着Xcode将使用这些.xib文件作为最终包)。

  • 现在添加所有新的.nib文件(由Xcode 3.2.5生成)到你的项目中(为了整洁,将它们放在一个自己的组中)。

  • 现在你可以清理,构建和运行非常喜欢,甚至为应用程序商店构建存档。

  • Quit Xcode 4.3.1 and start Xcode 3.2.5.
  • Create a new View-Based-Application project and add all the .xib files from your main project into it.
  • Set deployment target to iOS3.0 then do a Release Build and Run on device (use your generic provisioning profile if it doesn't pick this up automatically)
  • From Xcode, Reveal the .app in finder, then Show Package Contents to see all the .nib files within it (Xcode has converted the .xib files into .nib files).
  • For ease of use, copy the .nib files to another directory.
  • Quit Xcode 3.2.5 and start Xcode 4.3.1 and open your project.
  • Visit each xib and from the sidebar on the right deselect your app from the Target Membership (this means Xcode will not use these .xib files for the final package).
  • Now add all the new .nib files (as generated by Xcode 3.2.5) to your project (for neatness put them in a Group of their own).
  • Now you can Clean, Build and Run as much as you like and even build an Archive for the app store.

要证明正在使用正确的.nib文件,请使用md5从航站楼。在Finder中显示您的.app(或来自管理器的存档)以查看Xcode创建它的位置,然后显示包内容以查看.nib文件。将md5校验和与Xcode 3.2.5创建的.nib文件进行比较。

To prove the correct .nib files are being used, use md5 from the Terminal. Show your .app (or the Archive from Organiser) in Finder to see where Xcode created it then Show Package Contents to see the .nib files. Compare the md5 checksums with those from the .nib files created by Xcode 3.2.5.

请记住,每次修改xib时,它都不会被使用,直到你从Xcode 3.2.5。并将生成的.nib文件复制到您的保留目录。

Just remember that any time you modify a xib it wont get used until you build from Xcode 3.2.5. and copy the resulting .nib file to your holding directory.

这是不理想的,如果有人有更好的解决方案,我会热衷于听到它。与此同时,我希望这会有所帮助。

This isn't ideal and if anyone has a better solution that works I'll be keen to hear it. In the meantime I hope this helps.

这篇关于使用Xcode 4.3.x构建适用于iOS 3.0的通用应用程序 - NSKeyedUnarchiver例外的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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