dyld:库未加载:@rpath/libswiftCore.dylib 新 Xcode (10.2) 问题

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

dyld: Library not loaded: @rpath/libswiftCore.dylib problem with new Xcode (10.2)

swiftxcodemacos

提问by Chris Marshall

None of the referenced answers works. Something new has happened with Xcode 10.2

没有一个参考答案有效。Xcode 10.2 发生了一些新变化

This happens whether or not I use Swift 4.2 or 5.

无论我使用 Swift 4.2 还是 5,都会发生这种情况。

It happens immediately with a brand new, unedited command-line tool.

它使用全新的、未经编辑的命令行工具立即发生。

All you need to do, is create a MacOS command-line tool, and hit "run."

您需要做的就是创建一个 MacOS 命令行工具,然后点击“运行”。

You immediately get this error.

您会立即收到此错误。

Nothing I have done so far has fixed it.

到目前为止我所做的一切都没有解决它。

回答by Martin R

From the Swift 5 Release Notes for Xcode 10.2:

来自Xcode 10.2Swift 5 发行说明

Swift 5 Runtime Support for Command Line Tools Package

Starting with Xcode 10.2, Swift command line tools require the Swift libraries in macOS. They're included by default starting with macOS Mojave 10.14.4. In macOS Mojave 10.14.3 and earlier, there's an optional package to provide these runtime support libraries for Swift command line tools that you can download from More Downloads for Apple Developers. If you installed the beta version of this package, replace it with the release version. This package is only needed for Swift command line tools, not for apps with graphical user interfaces.

Swift 5 对命令行工具包的运行时支持

从 Xcode 10.2 开始,Swift 命令行工具需要 macOS 中的 Swift 库。从 macOS Mojave 10.14.4 开始,它们默认包含在内。在 macOS Mojave 10.14.3 及更早版本中,有一个可选包为 Swift 命令行工具提供这些运行时支持库,您可以从Apple Developers 的更多下载 下载。如果您安装了此软件包的测试版,请将其替换为发行版。此包仅适用于 Swift 命令行工具,不适用于具有图形用户界面的应用程序。

Note that:

注意:

  • This is onlynecessary if you are still on macOS 10.14.3. As soon as macOS is upgraded to 10.14.4, the Swift runtime libraries are provided by the operating system, and command line tools created with Xcode 5 run without the need to install the “Swift 5 Runtime package.”
  • On macOS 10.14.3 with Xcode 10.2 you must download and install the latest“Swift 5 Runtime package.” An earlier package which you might have installed with an Xcode 10.2 beta release does not work.
  • Early versions of the Xcode 10.2 beta release notes recommended to add a user-defined setting SWIFT_FORCE_STATIC_LINK_STDLIB=YESas a workaround, that is no longer necessary.
  • 这是唯一的,如果你仍然在MacOS 10.14.3必要的。macOS 升级到 10.14.4 后,操作系统会提供 Swift 运行时库,使用 Xcode 5 创建的命令行工具无需安装“Swift 5 运行时包”即可运行。
  • 在 macOS 10.14.3 和 Xcode 10.2 上,您必须下载并安装最新的“Swift 5 运行时包”。您可能随 Xcode 10.2 测试版一起安装的早期软件包不起作用。
  • Xcode 10.2 beta 发行说明的早期版本建议添加用户定义的设置SWIFT_FORCE_STATIC_LINK_STDLIB=YES作为解决方法,这不再是必要的。

回答by xeravim

This issue happened because I update XCode to 10.2 without updating the MacOS to the latest and the sdk that I used also not updated. Apparently these steps had solved my issues :

发生此问题是因为我将 XCode 更新到 10.2,而没有将 MacOS 更新到最新版本,而且我使用的 sdk 也没有更新。显然这些步骤已经解决了我的问题:

  1. Update your MacOS the latestList item
  2. for my case even updating all the required updates not solving the crash issue. In that case don't forget to check if your affected SDK/framework already rebuild from the latest XCode (10.2), since The problem went away after I rebuild the SDK with the latest XCode (10.2).
  3. For my case, we used jenkins to release the app, if the cloud still using old xcode and os, the .ipa will still crash. Need macos and xcode on jenkins cloud to be also updated.
  4. Because updating the cloud will affect everything (near the release date) so either I roll back the os and xcode, or I use the old sdk/framework (before rebuild state). But using the second option will make it crash on simulator but atleast no crash issue if release the app.
  1. 将您的 MacOS 更新为最新版本项目清单
  2. 就我而言,即使更新所有必需的更新也无法解决崩溃问题。在这种情况下,不要忘记检查您受影响的 SDK/框架是否已经从最新的 XCode (10.2) 重建,因为在我使用最新的 XCode (10.2) 重建 SDK 后问题就消失了。
  3. 就我而言,我们使用 jenkins 发布应用程序,如果云仍然使用旧的 xcode 和 os,.ipa 仍然会崩溃。需要更新 jenkins 云上的 macos 和 xcode。
  4. 因为更新云会影响一切(接近发布日期),所以要么回滚 os 和 xcode,要么使用旧的 sdk/framework(重建状态之前)。但是使用第二个选项会使它在模拟器上崩溃,但如果发布应用程序至少不会出现崩溃问题。

回答by Tim

I updated my macOS as was suggested, but it did not help without the following change in the Package.swift:

我按照建议更新了我的 macOS,但如果没有以下更改,它并没有帮助Package.swift

- // swift-tools-version:4.2
+ // swift-tools-version:5.0