xcode 升级到 iPhone SDK 3.0 导致 UIKit 问题
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1016204/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Upgrade to iPhone SDK 3.0 Causing UIKit Problems
提问by vfn
I have an existing project that I was working on, and I recently decided to update my iPhone SDK and updated to the latest 3.0 SDK.
我有一个正在处理的现有项目,我最近决定更新我的 iPhone SDK 并更新到最新的 3.0 SDK。
I update my SDK and go to open my existing project. Sure enough, there are some problems including some certificate problems and so on. Anyway, google and I were able to solve most of them, but I haven't had any luck on what I hope to be the last of my problems.
我更新我的 SDK 并打开我现有的项目。果然有一些问题,包括一些证书问题等等。无论如何,谷歌和我能够解决其中的大部分问题,但我希望成为最后一个问题,但我没有运气。
When running my program in the simulator, I now get
在模拟器中运行我的程序时,我现在得到
dyld: Library not loaded: /System/Library/Frameworks/UIKit.framework/UIKit Referenced from: /Developer/iGameLib/iGameLib/build/Debug-iphonesimulator/iGameLib.app/iGameLib Reason: image not found
dyld:库未加载:/System/Library/Frameworks/UIKit.framework/UIKit 引用自:/Developer/iGameLib/iGameLib/build/Debug-iphonesimulator/iGameLib.app/iGameLib 原因:找不到图像
Now, I discovered the UIKit has moved to
现在,我发现 UIKit 已经移动到
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0sdk/ System/Library/FrameWorks/UIKit
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0sdk/System/Library/FrameWorks/UIKit
and I have updated my target and project settings to point to that new framework location, but still when I build it, no luck.
我已经更新了我的目标和项目设置以指向那个新的框架位置,但是当我构建它时,仍然没有运气。
I have also tried clearing out the simulator's applications and settings, still no luck.
我也尝试清除模拟器的应用程序和设置,但仍然没有运气。
The referencing .app is cleared when I run the "clean" menuitem, I have confirmed this, so clearly something in my project settings are still pointing to use the old UIKit location.
当我运行“clean”菜单项时,引用的 .app 被清除,我已经确认了这一点,所以很明显我的项目设置中的某些内容仍然指向使用旧的 UIKit 位置。
Where should I be looking?
我应该去哪里找?
I've gone as far as I can to help myself but I'm afraid I'm at a loss here. I don't see it under the target settings, or the project settings, or the plist, or any of the other files within my project.
我已经尽力帮助自己了,但恐怕我在这里不知所措。我没有在目标设置、项目设置、plist 或我的项目中的任何其他文件下看到它。
回答by vfn
I was getting the same error
我遇到了同样的错误
dyld: Library not loaded: /System/Library/Frameworks/UIKit.framework/UIKit
dyld:库未加载:/System/Library/Frameworks/UIKit.framework/UIKit
The solution on my case was simply quit Xcode and try again.
我的情况的解决方案是简单地退出 Xcode 并重试。
回答by vfn
OK, SO I HAVE THE ANSWER!!!
好的,所以我有答案!!!
Quite simply, Xcode is not changing all of the variables correctly in the actual .xcodeproj file. So, here are the steps I took.
很简单,Xcode 并未正确更改实际 .xcodeproj 文件中的所有变量。所以,这是我采取的步骤。
Get out of Xcode, you've got to do this job at the terminal. Bring up a terminal and go to where your project is. Find your .xcodeproj and go into it as if it were a directory. It looks like an actual file in finder, but it is one of those package directories.
离开 Xcode,你必须在终端上完成这项工作。打开一个终端并转到您的项目所在的位置。找到您的 .xcodeproj 并进入它,就像它是一个目录一样。它看起来像 finder 中的一个实际文件,但它是那些包目录之一。
Now, I couldn't get textedit to allow me to edit it, but you can go into nano, so like I did
现在,我无法使用 textedit 来编辑它,但是您可以进入 nano,就像我一样
sudo nano project.pbxproj which is under my .xcodeproj file/folder/package/whatever.
sudo nano project.pbxproj 位于我的 .xcodeproj 文件/文件夹/包/任何内容下。
In this file, you need to find where the SDKROOT is set. Chances are there are a few places it is referenced, but you're looking for SDKROOT = iphoneos2.2.1 or something similar. Change ALL OF THESE (there are a few) to SDKROOT = iphoneos3.0
在这个文件中,需要找到SDKROOT的设置位置。可能有几个地方引用了它,但您正在寻找 SDKROOT = iphoneos2.2.1 或类似的东西。将所有这些(有几个)更改为 SDKROOT = iphoneos3.0
Now, you're half way there. do ctrl x and save the file. Next you're going to do ls and find out what the .pbxuser file is. Mine is myname.pbxuser. run the same command of
现在,你已经成功了一半。执行 ctrl x 并保存文件。接下来,您将执行 ls 并找出 .pbxuser 文件是什么。我的是 myname.pbxuser。运行相同的命令
sudo nano myname.pbxuser
须藤纳米 myname.pbxuser
In this file, there are a HUGE number of references to the 2.1 iphone sdk directory. Do a search/replace of iPhoneSimulatorOLDVERSION.sdk, in my case it was iPhoneSimulator2.1.sdk and change the 2.1 to 3.0. Be very careful with this though, I wouldn't want to know what happens when you mess this file up.
在这个文件中,有大量对 2.1 iphone sdk 目录的引用。搜索/替换 iPhoneSimulatorOLDVERSION.sdk,就我而言,它是 iPhoneSimulator2.1.sdk,并将 2.1 更改为 3.0。不过要非常小心,我不想知道当你把这个文件弄乱时会发生什么。
Save it and open xcode. CLEAN the project and build and run. Presto!
保存并打开xcode。清理项目并构建和运行。快!
回答by Andrew Pouliot
Check your target settings
Make sure you're actually linking to all of those frameworks in the Target (check under "link binary with libraries")Make sure you've chosen the 3.0 sdk as your base SDK
Create a blank project and add your frameworks as before; if you still have issues, probably a borked SDK install
检查您的目标设置
确保您实际上链接到目标中的所有框架(检查“链接二进制与库”)确保您已选择 3.0 sdk 作为基础 SDK
创建一个空白项目并像以前一样添加您的框架;如果您仍然有问题,可能是安装了一个无聊的 SDK
BTW, you shouldn't have to re-add sdk frameworks, as the paths are relative to the current SDK
顺便说一句,您不必重新添加 sdk 框架,因为路径是相对于当前 SDK 的
Just trying to be helpful… not sure I can debug from here :)
只是想提供帮助......不确定我可以从这里调试:)
回答by DefenestrationDay
I just deleted the UIKit.framework from the 'Frameworks' folder, right-clicked and added it back again. Clean build, and no problem..
我刚刚从“Frameworks”文件夹中删除了 UIKit.framework,右键单击并再次添加回来。干净的构建,没有问题..
回答by RexOnRoids
I have had some similar problems with Xcode that seem to have no apparent cause. The fact of the matter is that Xcode does still have bugs here and there and sometimes you WILL run into a wall.
我在 Xcode 上遇到了一些类似的问题,但似乎没有明显的原因。事实是 Xcode 仍然到处都有错误,有时你会碰壁。
My Experience:Similar to your situation somewhat, on one particular occasion, an Xcode project I was working just stopped building for whatever mysterious reason, and no amount of cleaning, googling or SO-ing provided me any answers. So I simply created a FRESH, NEW project and filled the source-code from my corrupt project into that of the new project. The new project used the SAME source, libraries, resources, settings, mind you -- and yet it built with no problems. It took about 20-25 minutes to make the transfer but considering that I had spent several HOURS trying to address a bug that would not reveal itself in the corrupt project, the time was well worth it.
我的经验:有点类似于你的情况,在一个特定的场合,我正在工作的 Xcode 项目因为任何神秘的原因停止构建,并且没有任何清理、谷歌搜索或 SO-ing 给我任何答案。所以我简单地创建了一个全新的项目,并将我损坏的项目的源代码填充到新项目的源代码中。新项目使用相同的源代码、库、资源、设置,请注意——但它的构建没有任何问题。进行转移大约需要 20-25 分钟,但考虑到我花了几个小时试图解决一个不会在损坏的项目中显示出来的错误,时间是值得的。
So, I'd suggest doing what I did: Maybe try creating a fresh project and transfer your old source and resources over.
所以,我建议做我所做的:也许尝试创建一个新项目并转移您的旧源和资源。
Good Luck
祝你好运
回答by RexOnRoids
I had the same problem using Xcode 3.2.1 but it was solved in an easier manner. I realized I had recently disabled my target's environment variables, specifically ones to do with memory debugging (NSDebugEnabled, NSZombieEnabled, NSAutoreleaseFreedObjectCheckEnabled, MallocStackLogging, MallocStackLoggingNoCompact). The app ran once in the simulator after removing the environment variables but never again after that.
我在使用 Xcode 3.2.1 时遇到了同样的问题,但它以更简单的方式解决了。我意识到我最近禁用了目标的环境变量,特别是与内存调试有关的变量(NSDebugEnabled、NSZombieEnabled、NSAutoreleaseFreedObjectCheckEnabled、MallocStackLogging、MallocStackLoggingNoCompact)。删除环境变量后,该应用程序在模拟器中运行了一次,但之后再也没有运行过。
Quitting Xcode, the Simulator, restarting Xcode and doing a complete clean of the target (including it's dependencies off course) brought me back to a good state.
退出 Xcode,模拟器,重新启动 Xcode 并彻底清除目标(包括它的依赖项)使我回到了一个良好的状态。
回答by user260796
Same problem when launching my application without debugging. In my experience the produced binary does not seem to be the culprit.
在没有调试的情况下启动我的应用程序时出现同样的问题。根据我的经验,生成的二进制文件似乎不是罪魁祸首。
I created an app from the xcode wizard which does launch OK in the simulator (let's call it testApp, my application being called myApp), I tried to figure out where is the difference with my app.
我从 xcode 向导创建了一个应用程序,它在模拟器中启动正常(我们称之为 testApp,我的应用程序称为 myApp),我试图找出我的应用程序的不同之处。
otool -L myApp
gives correct (relative paths) to the frameworks, same as testApp
otool -L myApp
为框架提供正确的(相对路径),与 testApp 相同
ps -E
DYLD_ROOT_PATH, DYLD_FALLBACK_FRAMEWORK_PATH, DYLD_FRAMEWORK_PATH, DYLD_LIBRARY_PATH environment variables needed by ld to locate the framework
are OK for myApp compared to the values of these variables when testApp is launched
ps -E
与 testApp 启动时这些变量的值相比,ld 定位框架所需的 DYLD_ROOT_PATH、DYLD_FALLBACK_FRAMEWORK_PATH、DYLD_FRAMEWORK_PATH、DYLD_LIBRARY_PATH 环境变量对于 myApp 来说是可以的
I suspect that the problem lies somewhere in the communicartion between XCode and the simulator once the app is launched ... altough I can't find what's wrong ...
我怀疑问题出在应用程序启动后 XCode 和模拟器之间的通信中……尽管我找不到问题所在……
The solution that worked (at least for me) have certainly some big side effects but here it is : quit xcode browse the content of the package myApp.xcodeproj unlock .model1v3 and .pbxuser for modification (the lock in the information panel (cmd-I on the file)) delete these two files start xcode and retry to launch your application from there
有效的解决方案(至少对我而言)肯定有一些很大的副作用,但它是:退出 xcode 浏览包 myApp.xcodeproj 解锁 .model1v3 和 .pbxuser 的内容进行修改(信息面板中的锁(cmd-我在文件上))删除这两个文件启动 xcode 并重试从那里启动您的应用程序