无法在模拟器中运行应用程序:Xcode beta 6 iOS 8

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24033417/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 00:23:26  来源:igfitidea点击:

Unable to run app in Simulator: Xcode beta 6 iOS 8

iosxcodeswiftios8

提问by Hemant Chittora

I am unable to launch my app on simulator using Xcode 6 beta and iPhone 5s simulator. First I am getting an error message from Simulator

我无法使用 Xcode 6 beta 和 iPhone 5s 模拟器在模拟器上启动我的应用程序。首先,我收到来自模拟器的错误消息

"Unable to boot the iOS simulator"

“无法启动iOS模拟器”

and then after Xcode is showing me following error,

然后在 Xcode 向我显示以下错误之后,

Unable to run app in Simulator
An error was encountered while running (Domain = DTiPhoneSimulatorErrorDomain, Code = 2)

无法在模拟器中运行应用程序运行
时遇到错误(域 = DTiPhoneSimulatorErrorDomain,代码 = 2)

Xcode Error

Xcode 错误

回答by apascual

I solved it following these steps:

我按照以下步骤解决了它:

  1. Open Xcode 6 beta
  2. Go to the menu Xcode > Open Developer Tool > iOS Simulator
  3. Even if an error dialog shows up, you still would have access to the iOS Simulator's menu
  4. Select Hardware > Device > Manage Devices
  5. Click on the little + sign at the bottom
  6. Add (if missing) all the devices that you want, or delete and recreate the ones malfunctioning.
  7. If anyone of the simulator is not working then right click on it and delete it and then re-create it again
  1. 打开 Xcode 6 测试版
  2. 转到菜单 Xcode > Open Developer Tool > iOS Simulator
  3. 即使出现错误对话框,您仍然可以访问 iOS 模拟器的菜单
  4. 选择硬件 > 设备 > 管理设备
  5. 点击底部的小+号
  6. 添加(如果缺少)您想要的所有设备,或者删除并重新创建出现故障的设备。
  7. 如果模拟器中的任何一个不起作用,请右键单击它并删除它,然后重新创建它

enter image description here

在此处输入图片说明

回答by ayalcinkaya

  • Make sure you choose Xcode 6 as Command Line Tools in Preferences > Locations Section
  • 确保在首选项 > 位置部分中选择 Xcode 6 作为命令行工具

Xcode 6 Preferences

Xcode 6 首选项

  • Make sure you open Xcode 6 from Applications not from the setup file.

  • Finally restarting Mac solve the problem in my case.

  • 确保从应用程序而不是从安装文件中打开 Xcode 6。

  • 最后重新启动 Mac 解决了我的问题。

回答by Alexandre

After I found some solutions on the web, a combination of procedures worked for me:

我在网上找到了一些解决方案后,一系列程序对我有用:

  1. Close Xcode and iOS Simulator (and all related applications)

  2. Install (or reinstall) Xcode6-Beta to Applications folder (direct from the .dmg file)

  3. Open Xcode6-Beta and go to Xcode -> Preferences -> Locations -> Command Line Tools and select "Xcode 6.0" (be sure that you've selected the one in Applications folder)

  4. Launch the iOS Simulator and go to iOS Simulator -> Reset Content and Settings...

  5. Close all the applications and restart your mac (I unchecked "Reopen windows...")

  6. Open Xcode6-beta and test the iOS Simulator

  1. 关闭 Xcode 和 iOS Simulator(以及所有相关应用程序)

  2. 将 Xcode6-Beta 安装(或重新安装)到 Applications 文件夹(直接从 .dmg 文件)

  3. 打开 Xcode6-Beta 并转到 Xcode -> Preferences -> Locations -> Command Line Tools 并选择“Xcode 6.0”(确保您已选择 Applications 文件夹中的那个)

  4. 启动 iOS 模拟器并转到 iOS 模拟器 -> 重置内容和设置...

  5. 关闭所有应用程序并重新启动您的 mac(我取消选中“重新打开窗口...”)

  6. 打开 Xcode6-beta 并测试 iOS 模拟器

Good luck

祝你好运

回答by Fred Yang

I'm using Xcode 6 beta 2 and has problem (error code = 4 in my case) running iPad simulators. I think I had the issue because I'm running dual Mac OS boot and the Xcode is launched from another startup disk

我正在使用 Xcode 6 beta 2 并且在运行 iPad 模拟器时遇到问题(在我的情况下为错误代码 = 4)。我想我遇到了这个问题,因为我正在运行双 Mac OS 启动并且 Xcode 是从另一个启动磁盘启动的

I did both steps recommended by @ayalcinkaya and @apascual, and this worked for me.

我做了@ayalcinkaya 和@apascual 推荐的两个步骤,这对我有用。

  • Change the "Command Line Tool" to Xcode BETA2 (from 5.1.1 in my case) in "Xcode->Preference->Locations"
  • Open Xcode 6 beta 2
  • Go to the menu Xcode > Open Developer Tool > iOS Simulator
  • Even if an error dialog shows up, you still would have access to the iOS Simulator's menu Select Hardware > Devices, and switch between iPad devices and this apparently made the simulators reconfigured
  • While the simulator is running, run the app with the selected simulator.
  • After going through this manual process once, everything is fine.
  • 在“Xcode->Preference->Locations”中将“Command Line Tool”更改为Xcode BETA2(在我的例子中是从5.1.1)
  • 打开 Xcode 6 测试版 2
  • 转到菜单 Xcode > Open Developer Tool > iOS Simulator
  • 即使出现错误对话框,您仍然可以访问 iOS 模拟器的菜单 选择硬件 > 设备,并在 iPad 设备之间切换,这显然使模拟器重新配置
  • 在模拟器运行时,使用选定的模拟器运行应用程序。
  • 完成此手动过程一次后,一切正常。

回答by footyapps27

This happens most of the times because another instance of the simulator is running in the dock.

大多数情况下会发生这种情况,因为模拟器的另一个实例正在 Dock 中运行。

Kill the other instance & things should work fine.

杀死另一个实例,一切正常。

回答by iGW

I also had this problem and found the solution by doing following steps:

我也遇到了这个问题,并通过执行以下步骤找到了解决方案:

  1. Initially I downloaded Xcode 6 library in Documentation section under the path Xcode --> Preferences --> Downloads and restart my xcode but didn't solve my problem.
  1. 最初,我在 Xcode --> Preferences --> Downloads 路径下的文档部分下载了 Xcode 6 库,然后重新启动我的 xcode,但没有解决我的问题。

After that ->

在那之后->

  1. Downloaded and installed the iOS 7.1 Simulator under the path Xcode --> Preferences --> Downloads.
  1. 在路径 Xcode --> Preferences --> Downloads 下下载并安装 iOS 7.1 Simulator。

Restart xcode again and the problem solved.

再次重启xcode,问题解决。

  1. I am facing same issue again next morning.
  1. 第二天早上我再次面临同样的问题。

Unsetting the DYLD_INSERT_LIBRARIES variable solves my problem:

取消设置 DYLD_INSERT_LIBRARIES 变量解决了我的问题:

a) Open terminal and type "sudo vi /etc/launchd.conf" command and press Enter
b) Press I "Insert" mode and change this

a) 打开终端并输入“sudo vi /etc/launchd.conf”命令,然后按 Enter
b) 按 I“插入”模式并更改它

    "setenv DYLD_INSERT_LIBRARIES /usr/lib/libimckit.dylib" 

to this

对此

    "unsetenv DYLD_INSERT_LIBRARIES /usr/lib/libimckit.dylib" 

and press esc to exit from insert mode.

然后按 esc 退出插入模式。

c) Save changes by typing ":wq" Press Enter
d) Reboot your system and problem solved.

c) 通过键入“:wq”保存更改按 Enter
d) 重新启动系统并解决问题。

enter image description here

在此处输入图片说明

Prior to that I didn't found any iOS version in front of each listed devices but after installation or by unsetting DYLD_INSERT_LIBRARIES variable I found the same in front of each devices.

在此之前,我没有在每个列出的设备前找到任何 iOS 版本,但在安装后或通过取消设置 DYLD_INSERT_LIBRARIES 变量后,我在每个设备前发现了相同的版本。

enter image description here

在此处输入图片说明

回答by lubert

What worked for me was removing all of the devices in "Manage Devices" and adding them back afterrebooting

对我有用的是删除“管理设备”中的所有设备并重新启动重新添加它们

回答by Golden Thumb

I got this problem after renaming the default folder name "Xcode-Beta2" to "Xcode". When I renamed it back to "Xcode-Beta2", the simulator worked as before.

将默认文件夹名称“Xcode-Beta2”重命名为“Xcode”后,我遇到了这个问题。当我将它重命名回“Xcode-Beta2”时,模拟器像以前一样工作。

回答by Kof

Clean -> Run fixed it for me.

清洁 -> 运行为我修复了它。

I've tried the rest, nothing helped. Although it may be required too.

我已经尝试了其余的,没有任何帮助。虽然它也可能是必需的。

回答by HBublitz

I've had the same problem, when running an app with the same name as a previously run different app.

在运行与以前运行的不同应用程序同名的应用程序时,我遇到了同样的问题。

Run "foo" -> make a new project named "foo" -> run -> error.

运行“foo”-> 新建一个名为“foo”的项目-> 运行-> 错误。

Whatsoever - it seems to me that there are several reasons for iOS-Simulator to say "ehm, what do you want from me? OK, I'll throw an error..." ;-)

无论如何 - 在我看来,iOS 模拟器有几个理由说“嗯,你想从我这里得到什么?好吧,我会抛出一个错误......”;-)

MY SOLUTION: Close iOS simulator, run app again.

我的解决方案:关闭 iOS 模拟器,再次运行应用程序。

That's it in most of cases like this.

在大多数情况下就是这样。