Xcode 10.2 无法在 iOS < 10 的模拟器上运行应用程序

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

Xcode 10.2 Failed to Run App on Simulator with iOS < 10

iosxcodedyldxcode10.2

提问by JyTee

I was playing around with Xcode 10.2 since the update and when I try to run my app on ANY simulator with iOS version less than 10, the simulator will not start and crash then show the error below:

自更新以来,我一直在玩 Xcode 10.2,当我尝试在任何 iOS 版本低于 10 的模拟器上运行我的应用程序时,模拟器将无法启动并崩溃,然后显示以下错误:

dyld: Library not loaded: /usr/lib/libauto.dylib Referenced from: /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation Reason: no suitable image found. Did find: /usr/lib/libauto.dylib: mach-o, but not built for iOS simulator

dyld:库未加载:/usr/lib/libauto.dylib 引用自:/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation 原因:找不到合适的图像。确实找到了:/usr/lib/libauto.dylib:mach-o,但不是为 iOS 模拟器构建的

I tried to create another new project fresh without touching anything, set the deployment target to iOS 9 and run on iOS 9 simulator again, same error was shown.

我尝试在不触及任何内容的情况下创建另一个新项目,将部署目标设置为 iOS 9 并再次在 iOS 9 模拟器上运行,显示相同的错误。

UPDATE

更新

It seems like this issue only occur when your code base contain swift. Created a new project with objective c code base did not crash the simulator. For swift yes.

似乎只有当您的代码库包含 swift 时才会出现此问题。使用客观的 c 代码库创建了一个新项目并没有使模拟器崩溃。是的。

SUMMARY

概括

  1. Xcode 10.2 contain swift code unable to run app on simulator with iOS 9
  2. I have done all the cleaning and delete derive data and the issue still persist.
  1. Xcode 10.2 包含无法在 iOS 9 模拟器上运行应用程序的 swift 代码
  2. 我已经完成了所有的清理和删除派生数据,但问题仍然存在。

Anyone has any idea ?

任何人有任何想法?

FINAL UPDATE

最后更新

Apple just release Xcode 10.2.1 and it is part of the known issue for simulator, please refer to the link below for the workaround/fix:

Apple 刚刚发布了 Xcode 10.2.1,它是模拟器已知问题的一部分,请参阅下面的链接以获取解决方法/修复:

https://developer.apple.com/documentation/xcode_release_notes/xcode_10_2_1_release_notes

https://developer.apple.com/documentation/xcode_release_notes/xcode_10_2_1_release_notes

Appreciate @russbishop 's reply, answer accepted

感谢@russbishop 的回复,已接受答案

回答by russbishop

This is a known bug affecting iOS 8.x and 9.x. You can work around it by creating /usr/lib/swiftdirectories in the relevant simulator runtime root.

这是影响 iOS 8.x 和 9.x 的已知错误。您可以通过/usr/lib/swift在相关模拟器运行时根目录中创建目录来解决此问题。

Downloaded simulator runtimes are located in /Library/Developer/CoreSimulator/Profiles/Runtimes.

下载的模拟器运行时位于/Library/Developer/CoreSimulator/Profiles/Runtimes.

For example, to fix the iOS 9.3 simulator:

例如,要修复 iOS 9.3 模拟器:

sudo mkdir '/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 9.3.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift'

回答by iOS

Me also got the same problem when run in iOS 9.0 simulator.

我在 iOS 9.0 模拟器中运行时也遇到了同样的问题。

From https://developer.apple.com/documentation/xcode_release_notes/xcode_10_2_1_release_notes

来自https://developer.apple.com/documentation/xcode_release_notes/xcode_10_2_1_release_notes

Simulators for iOS 9.3 and earlier might fail to launch Swift apps with the message: “dyld: Library not loaded: /usr/lib/libauto.dylib”. (49326587) Workaround: Run the following command in Terminal for the relevant version of iOS:

适用于 iOS 9.3 及更早版本的模拟器可能无法启动 Swift 应用程序并显示消息:“dyld:未加载库:/usr/lib/libauto.dylib”。(49326587) 解决方法:在终端中针对相关版本的 iOS 运行以下命令:

sudo mkdir '/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 9.3.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift'

For this apple given above solution in that link.

对于该链接中给出的上述解决方案的苹果。

Simply

简单地

--> open Terminal

--> 打开终端

--> Type this line with your required version (In my case i changed into iOS 9.3 to iOS 9.0)

--> 用你需要的版本输入这一行(在我的情况下,我改成 iOS 9.3 到 iOS 9.0)

Ex:sudo mkdir '/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 9.0.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift'

前任:sudo mkdir '/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 9.0.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift'

--> Enter password

--> 输入密码

--> Now clean Xcode and run again

--> 现在清理 Xcode 并再次运行

This above solution worked for me.

上述解决方案对我有用。

回答by Mihai Damian

This seems like an iOS Simulator bug. I see this happening on simulators with iOS 12.0 but not on those with 12.4.

这似乎是一个 iOS 模拟器错误。我在 iOS 12.0 的模拟器上看到了这种情况,但在 12.4 的模拟器上没有。

回答by Hugo F

Still get this bug with Xcode 10.3. (Skipped over 10.2.)

Xcode 10.3 仍然会出现此错误。(跳过 10.2。)

回答by Honey

I ran into this issue when I was doing unit-testing for iOS11and iOS12.1on Xcode11.1

我就遇到了这个问题,当我在做单元测试iOS11iOS12.1Xcode11.1

The solution was to just run the unit-tests with an iOS13 simulator.

解决方案是使用 iOS13 模拟器运行单元测试。

回答by cumanzor

A rather annoying workaround: use Xcode 10.1 to deploy on 9.x simulators for now. It's the only way I've been able to get around this.

一个相当烦人的解决方法:暂时使用 Xcode 10.1 在 9.x 模拟器上进行部署。这是我能够解决这个问题的唯一方法。

回答by Ade Omole

None of the above worked for me. My issue is the same as this but was building an app for macOS.

以上都不适合我。我的问题与此相同,但正在为macOS.

Running Xcode 11project target 10.4whilst my OS is Mojave 10.4.6.

运行Xcode 11项目的目标10.4,而我的操作系统是Mojave 10.4.6

I had to install Xcode 10.3and use that instead. No problems since.

我不得不安装Xcode 10.3并使用它。从那以后没有问题。

My guess is its a problem with OS, Xcode versionand project target.

我的猜测是操作系统Xcode version和项目目标的问题。

回答by FSUWX2011

Having to use Xcode 10.2.1 I had this issue with another library and ended up having to set always embed swift libraries to YES in build settings since the library in question was in a framework file I had.

不得不使用 Xcode 10.2.1 我在另一个库中遇到了这个问题,最终不得不在构建设置中将 always embed swift libraries 设置为 YES,因为有问题的库在我拥有的框架文件中。

回答by Hino B

Updating to Xcode 10.3 has fixed it for me.

更新到 Xcode 10.3 已经为我修复了它。