Xcode 4.2。运行时卡住“附加到我的应用程序”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8021426/
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
Xcode 4.2. gets stuck "Attaching to myapp" when running
提问by Alexander Fradiani
In xcode 4.2, sometimes when you're going to run your ios proj on simulator, the status windows says "Attaching to myapp", and just gets stuck there... until you cancel. Now, this has been asked before: XCode 4 hangs at "Attaching to (app name)"
在 xcode 4.2 中,有时当您要在模拟器上运行 ios proj 时,状态窗口会显示“附加到 myapp”,然后卡在那里……直到您取消为止。现在,以前有人问过这个问题: XCode 4 挂在“附加到(应用程序名称)”
and surprisingly, besides the accepted answer on that thread, there are at least 10 other possible solutions others have been adding, all for the same issue, people says one of them worked while the others didn't...
令人惊讶的是,除了该线程上已接受的答案之外,其他人还添加了至少 10 种其他可能的解决方案,所有这些都是针对同一问题,人们说其中一个有效,而其他人则没有......
please note, this is not a sequence of steps. each one is a possible solution:
请注意,这不是一系列步骤。每一个都是一个可能的解决方案:
1-restart xcode and/or restart simulator (reset content and settings) and/or restart computer.
1-重新启动 xcode 和/或重新启动模拟器(重置内容和设置)和/或重新启动计算机。
2-click on project name in project navigator. in build settings tab, go to packaging and make sure that "Product Name" is the same that the one xcode says simulator is attaching to when running. if they are different, it will fail.
2-在项目导航器中单击项目名称。在构建设置选项卡中,转到打包并确保“产品名称”与 xcode 所说的模拟器在运行时附加到的名称相同。如果它们不同,它将失败。
3-go to your projectname.xcodeproj folder. inside there delete anything named with your userid. when you reopen xcode those files will be recreated and it should work…
3-转到您的 projectname.xcodeproj 文件夹。在那里删除以您的用户 ID 命名的任何内容。当你重新打开 xcode 时,这些文件将被重新创建,它应该可以工作......
4-Manually delete the build directory for your project.
4-手动删除项目的构建目录。
5-Go to organizer window. select Projects, select your app in the left hand side and then delete over "Derived Data"
5-转到组织者窗口。选择项目,在左侧选择您的应用程序,然后删除“派生数据”
6-Check Launch option is set to "Automatically" in Product->Edit Scheme, "Run" scheme.
6-检查启动选项设置为“自动”在产品->编辑方案,“运行”方案。
7-In Project->"Edit Schemes"->Run. Change the Debugger from GDB to None (this doesn't make sense to me..).
7-在项目->“编辑方案”->运行。将调试器从 GDB 更改为无(这对我来说没有意义......)。
8-Kill the process gdb-i386-apple-darwin from Activity Monitor. this is assuming gdb is not responding.
8-从活动监视器中杀死进程 gdb-i386-apple-darwin。这是假设 gdb 没有响应。
9-In "Product"->Edit Scheme. in Run, click yourappname.app, choose other, navigate to your .app in your project. now run.
9-在“产品”->“编辑方案”中。在运行中,单击 yourappname.app,选择其他,导航到您项目中的 .app。现在运行。
10-Check that you don't have two different Info.plist in your project. if you do, remove the bad one.
10-检查您的项目中是否没有两个不同的 Info.plist。如果这样做,请删除坏的。
In my case, none of them do the job. My project builds succesfully, everything seems fine, .plist, bundle identifier, name, etc.. and still can't pass the "attaching" part. i don't understand the reason of this, so any suggestions to fix it and possibly understand the problem i'll really appreciate it.
就我而言,他们都没有完成这项工作。我的项目成功构建,一切似乎都很好,.plist、包标识符、名称等。但仍然无法通过“附加”部分。我不明白这是什么原因,所以任何修复它的建议并可能理解这个问题,我会非常感激。
回答by Nick
New projects were failing to launch in the simulator, getting stuck on the attach step.
新项目无法在模拟器中启动,卡在附加步骤中。
This seems to be after Xcode 4.3 was installed, but I can't recall the last new project I created.
这似乎是在安装了 Xcode 4.3 之后,但我不记得我创建的最后一个新项目。
This is what worked for me, the clue coming from this thread...
这对我有用,线索来自这个线程......
Project->"Edit Schemes"->Run. Change the Debugger from LLDB to GDB
项目->“编辑方案”-> 运行。将调试器从 LLDB 更改为 GDB
Another computer with the same version of Xcode works fine. Maybe my LLDB is corrupt?
另一台具有相同 Xcode 版本的计算机工作正常。也许我的 LLDB 已损坏?
回答by nekoichan
Did you recently upgrade to OSX 10.7.2? I started having the same problem after I upgraded. I noticed that the Simulator always get stuck if I'm connected to a Wi-Fi network that forces Captive Portal authentication. This happens with other apps as well (Chrome, Safari). I'm not really sure why this happens, but I did read that 10.7.2 has issues with Captive Portal authentication.
您最近是否升级到 OSX 10.7.2?我升级后开始遇到同样的问题。我注意到如果我连接到强制 Captive Portal 身份验证的 Wi-Fi 网络,模拟器总是会卡住。其他应用程序(Chrome、Safari)也会发生这种情况。我不确定为什么会发生这种情况,但我确实读到 10.7.2 存在 Captive Portal 身份验证问题。
Anyway, in my case, I repaired disk permission from Disk Utility and rebooted my machine. This seems to resolve the issue.
无论如何,就我而言,我从“磁盘工具”修复了磁盘权限并重新启动了我的机器。这似乎解决了这个问题。
回答by Wisebee
It seems different in my case and also solved in a different way. If you got stuck every time after drop some files or folders into your project with the 'Create folder references for any added folders' way, this will be the solution.
在我的情况下似乎不同,并且也以不同的方式解决。如果每次使用“为任何添加的文件夹创建文件夹引用”方式将一些文件或文件夹放入项目后都卡住了,这将是解决方案。
Click the project node(the root node) on Xcode's project navigator and select target node. It's under the 'TARGETS'. Then click the 'Build Phases' tab. There are 4 sections of some list and you can click the triangle to expand the list. You need to concentrate on the 'Compile Sources' and 'Copy Bundle Resources' section. Code fileslike .m must be placed on the 'Compile Sources'section and are compiled automatically. Resource fileslike .jpg must be placed on the 'Copy Bundle Resources'section and are copied into the project's package. So, if the dropped files and folders are not in the 'Copy Bundle Resources' list, just drag it form the project navigator and drop onto the list. That will solve the problem.
在 Xcode 的项目导航器上单击项目节点(根节点)并选择目标节点。它在“目标”下。然后单击“构建阶段”选项卡。某些列表有 4 个部分,您可以单击三角形展开列表。您需要专注于“编译源”和“复制捆绑资源”部分。.m 之类的代码文件必须放在“编译源”部分并自动编译。.jpg 等资源文件必须放在“复制捆绑资源”上部分并复制到项目的包中。因此,如果放置的文件和文件夹不在“复制捆绑资源”列表中,只需将其从项目导航器中拖放到列表中即可。这将解决问题。
If it doesn't work, delete all the referenced files and folders, click '+' buttonon the resource (or compile) section and click 'Add other...' button. Then you can include files and folders as the 'Create folder references for any added folders' way. I think the 'drag and drop' works well after the '+ button' way is done once.
如果它不起作用,请删除所有引用的文件和文件夹,单击资源(或编译)部分上的“+”按钮,然后单击“添加其他...”按钮。然后,您可以将文件和文件夹包含为“为任何添加的文件夹创建文件夹引用”的方式。我认为在“+ 按钮”方式完成一次后,“拖放”效果很好。
In addition, 'Resource' may not allowed for folder name.
此外,文件夹名称可能不允许使用“Resource”。
I experienced the 'stuck' problem every time when I attach files and folders as reference on Xcode 4.2 ~ 4.3.3. Reinstalling mac was a useless effort for me.
每次在 Xcode 4.2 ~ 4.3.3 上附加文件和文件夹作为参考时,我都会遇到“卡住”问题。重新安装 mac 对我来说是无用的努力。
回答by Z S
Just rebooting the computer worked for me.
只是重新启动计算机对我有用。
回答by sdjuan
Tried all the solutions but none applied to my case. XCode 4.2, OS X 10.6.8 Found that the Info.plist bundle identifier had been accidentally deleted when adding a custom app icon. Adding that back fixed the problem. Anyway that's my fix, hope it helps someone.
尝试了所有解决方案,但没有一个适用于我的案例。XCode 4.2, OS X 10.6.8 添加自定义应用程序图标时发现 Info.plist 包标识符被意外删除。添加回来解决了问题。无论如何,这是我的修复,希望它可以帮助某人。
Also before figuring out that, found I could start the simulator from another app and then use the app icon on the simulator for the app that would not attach, and start it up that way.
同样在弄清楚之前,发现我可以从另一个应用程序启动模拟器,然后将模拟器上的应用程序图标用于不会附加的应用程序,然后以这种方式启动它。
回答by Will Ayd
seems like there seem to be a lot of things causing this, but one thing that worked for me was simply cleaning out the build folder by pressing Cmd+Option+Shift+K or alternately if you select the Product dropdown in the toolbar and hold the Option button you should see the "Clean Build Folder" option appear
似乎有很多事情导致了这种情况,但对我有用的一件事就是通过按 Cmd+Option+Shift+K 或交替地如果您选择工具栏中的产品下拉菜单并按住选项按钮,您应该会看到“清理构建文件夹”选项出现
回答by WeZZard
I also tried all solutions in that topic but all failed. But finally it was found out that what was went wrong.
我也尝试了该主题中的所有解决方案,但都失败了。但最后才发现是哪里出了问题。
What made this issue occurred is that some settings in Target->Build Settings was got modified by me for including C headers. And after I added all C headers and make it built. This issue occurred.
导致此问题发生的原因是我修改了 Target->Build Settings 中的某些设置以包含 C 头文件。在我添加了所有 C 头文件并使其构建之后。出现了这个问题。
It might be only works on the situation I described before.
它可能只适用于我之前描述的情况。
I just created an empty project and check all items in Target->Build Settings between the attaching-stuck app and the empty one. It was found that some items in the attaching-stuck one was different from the empty one.
我刚刚创建了一个空项目,并在附加卡住的应用程序和空的应用程序之间检查 Target->Build Settings 中的所有项目。发现粘住的物品中有些物品与空物品不同。
So I deleted it and make it attached successfully.
所以我删除了它并使其成功附加。
回答by Berby Huang
I tried all of the solutions above but without luck ... When I search for simular problem here : Xcode error: failed to launch [directory] -- invalid host string: 'localhost'
我尝试了上述所有解决方案,但没有运气......当我在这里搜索类似问题时: Xcode 错误:无法启动 [目录] -- 无效的主机字符串:'localhost'
I found it fixed my problem! Hope this helps those who are still searching for a clue .
我发现它解决了我的问题!希望这可以帮助那些仍在寻找线索的人。
回答by epsilonpsi
Upgrading to XCode 4.6.2 resolved this issue for me
升级到 XCode 4.6.2 为我解决了这个问题
回答by MaheshShanbhag
Even if the app is not attaching after cleaning the project, changing the app name, restart the by resetting the simulator, and if you are using LLDB compiler, it is because the LLDB compiler is not able to connect to the local debug server in order to solve this, take a look at this
即使app在清理项目后没有附加,更改app名称,通过重置模拟器重新启动,如果您使用的是LLDB编译器,那是因为LLDB编译器无法按顺序连接到本地调试服务器要解决这个问题,看看这个
Why does the LLDB Debugger constantly fail to attach?
This really solves your problem!
这真的可以解决你的问题!