ios dyld:库未加载:@rpath/libswiftCore.dylib

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

dyld: Library not loaded: @rpath/libswiftCore.dylib

iosswiftxcodedyld

提问by user3751185

I am trying to run a Swift app on my iPhone 4s. It works fine on the simulator, and my friend can successfully run it on his iPhone 4s. I have iOS 8 and the official release of Xcode 6.

我正在尝试在我的 iPhone 4s 上运行一个 Swift 应用程序。它在模拟器上运行良好,我的朋友可以在他的 iPhone 4s 上成功运行它。我有 iOS 8 和 Xcode 6 的官方版本。

I have tried

我试过了

  • Restarting Xcode, iPhone, computer
  • Cleaning & rebuilding
  • Revoking and creating new certificate/provision profile
  • Runpath Search Paths is $(inherited) @executable_path/Frameworks
  • Embedded Content Contains Swift Code is 'Yes'
  • Code Signing Identity is developer
  • 重启 Xcode、iPhone、电脑
  • 清洁和重建
  • 撤销和创建新的证书/配置文件
  • 运行路径搜索路径是 $(inherited) @executable_path/Frameworks
  • 嵌入的内容包含 Swift 代码是“是”
  • 代码签名身份是开发人员

Below is the error in entirety

以下是完整的错误

dyld: Library not loaded: @rpath/libswiftCore.dylib
  Referenced from: /private/var/mobile/Containers/Bundle/Application/LONGSERIALNUMBER/AppName.app/AppName
  Reason: no suitable image found.  Did find:
    /private/var/mobile/Containers/Bundle/Application/LONGSERIALNUMBER/AppName.app/Frameworks/libswiftCore.dylib: mmap() error 1 at
address=0x008A1000, size=0x001A4000 segment=__TEXT in Segment::map() mapping
/private/var/mobile/Containers/Bundle/Application/LONGSERIALNUMBER/APPLICATION_NAME/Frameworks/libswiftCore.dylib

回答by TALAA

For me none of the previous solutions worked. We discovered that there is an "Always Embed Swift Standard Libraries" flag in the Build Settings that needs to be set to YES. It was NO by default!

对我来说,以前的解决方案都没有奏效。我们发现 Build Settings 中有一个“Always Embed Swift Standard Libraries”标志需要设置为 YES。默认情况下是NO!

Build Settings > Always Embed Swift Standard Libraries

Build Settings > Always Embed Swift Standard Libraries

After setting this, clean the project before building again.

设置后,在再次构建之前清理项目。

For keen readers some explanationThe most important part is:

对于敏锐的读者一些解释最重要的部分是:

set the Embedded Content Contains Swift Code (EMBEDDED_CONTENT_CONTAINS_SWIFT) build setting to YES in your app as shown in Figure 2. This build setting, which specifies whether a target's product has embedded content with Swift code, tells Xcode to embed Swift standard libraries in your app when set to YES.

在您的应用程序中将 Embedded Content Contains Swift Code (EMBEDDED_CONTENT_CONTAINS_SWIFT) 构建设置设置为 YES,如图 2 所示。此构建设置指定目标的产品是否已使用 Swift 代码嵌入内容,它告诉 Xcode 在您的应用程序中嵌入 Swift 标准库当设置为 YES 时。

enter image description here

在此处输入图片说明

The flag was formerly called Embedded Content Contains Swift Code

这面旗帜以前被称为 Embedded Content Contains Swift Code

回答by royherma

Surprisingly enough, all i did was "Clean" my project(shift+cmd+K) and it worked. Did seem to be related to the certificate though.

令人惊讶的是,我所做的只是“清理”我的项目(shift+cmd+K)并且它起作用了。虽然似乎与证书有关。

回答by jemmons

I started getting this error when I removed:

当我删除时,我开始收到此错误:

@executable_path/Frameworks

from Runpath Search Pathsin my build settings. Replacing it fixed everything up again (thank goodness for source control!)

Runpath Search Paths我的构建设置中。更换它再次修复了一切(感谢源代码管理!)

I don't know how it got there, but it appears to be needed for a binary to find its embedded Swift runtime.

我不知道它是如何到达那里的,但二进制文件似乎需要它来找到其嵌入的 Swift 运行时。

回答by Mustafa

For the device, you also need to add the dynamic framework to the Embedded binariessection in the Generaltab of the project.
enter image description here

对于设备,您还需要将动态框架添加到项目选项卡中的Embedded binaries部分General
在此处输入图片说明

回答by Bonnie

In Xcode 8 the option for Embedded Content Contains Swift Codeoption is no longer available.

在 Xcode 8 中,选项Embedded Content Contains Swift Code选项不再可用。

It has been renamed to "Always Embed Swift Standard Libraries = YES"

它已更名为 "Always Embed Swift Standard Libraries = YES"

enter image description here

在此处输入图片说明

回答by Vijay Sundaram

I think it's a bug when certificates are generated directly from Xcode. To resolve (at least in Xcode 6.1 / 6A1052d):

我认为这是直接从 Xcode 生成证书时的错误。解决(至少在 Xcode 6.1 / 6A1052d 中):

  1. go to the Apple Developer website where certificates are managed: https://developer.apple.com/account/ios/certificate/certificateList.action
  2. select your certificate(s) (which should show "Managed by Xcode" under "Status") and "Revoke" it
  3. follow instructions here to manually generate a new certificate: https://developer.apple.com/library/ios/documentation/IDEs/Conceptual/AppDistributionGuide/MaintainingCertificates/MaintainingCertificates.html#//apple_ref/doc/uid/TP40012582-CH31-SW32
  4. go to Xcode > Preferences > Accounts > [your Apple ID] > double-click your team name > hit refresh button to update certificates and provisioning profiles
  1. 转到管理证书的 Apple Developer 网站:https: //developer.apple.com/account/ios/certificate/certificateList.action
  2. 选择您的证书(应在“状态”下显示“由 Xcode 管理”)并“撤销”它
  3. 按照此处的说明手动生成新证书:https: //developer.apple.com/library/ios/documentation/IDEs/Conceptual/AppDistributionGuide/MaintainingCertificates/MaintainingCertificates.html#//apple_ref/doc/uid/TP40012582-CH31- SW32
  4. 转到 Xcode > Preferences > Accounts > [your Apple ID] > 双击您的团队名称 > 点击刷新按钮更新证书和配置文件

回答by nalexn

OK, sharing here another cause of this error. It took me a few hours to sort this out.

好的,在这里分享这个错误的另一个原因。我花了几个小时来解决这个问题。

In my case the trust policy of my certificate in Keychain Access was Always Trust, changing it back to defaults solved the problem.

在我的情况下,我的证书在 Keychain Access 中的信任策略是Always Trust,将其改回默认值解决了问题。

In order to open the certificate settings window double click the certificate in the Keychain Access list of certificates.

为了打开证书设置窗口,双击证书钥匙串访问列表中的证书。

enter image description hereenter image description here

在此处输入图片说明在此处输入图片说明

回答by DonnaLea

I was having this issue with running my Swift tests (but not my app). It turns out that the test needed to have more than @executable_path/Frameworksin it's Runpath Search Pathsbuild setting for the test target. Setting the Runpath Search Paths to the following worked a charm for me:

我在运行 Swift 测试(但不是我的应用程序)时遇到了这个问题。事实证明,测试需要的不仅仅是测试目标@executable_path/FrameworksRunpath Search Paths构建设置。将运行路径搜索路径设置为以下对我来说很有魅力:

$(inherited)
@executable_path/Frameworks
@loader_path/Frameworks

回答by Jim Bray

This issue occurs again in Xcode 10.2. You must download and install the following package from Apple. It provides Swift 5 Runtime Support for Command Line Tools.

这个问题在Xcode 10.2 中再次出现。您必须从 Apple 下载并安装以下软件包。它为命令行工具提供Swift 5 运行时支持

https://support.apple.com/kb/DL1998?locale=en_US

https://support.apple.com/kb/DL1998?locale=en_US

回答by loretoparisi

You have to set the Runpath Search Pathsto @executable_path/Frameworksas showed in the following screenshot of Build Settings:

你必须设置Runpath Search Paths@executable_path/Frameworks作为显示在生成设置的下面的截图:

enter image description here

在此处输入图片说明

If you have any embedded frameworks made in Swift, than you can set to YESthe Build Options Embedded Content Contains Swift Code.

如果您有任何用 Swift 制作的嵌入式框架,那么您可以设置为YESBuild Options Embedded Content Contains Swift Code