ios dyld:库未加载:@rpath/libswiftCore.dylib / 找不到图像

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

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

iosswiftxcode6

提问by Stig Omdal

I am running my app from xcode to my iOS device and I get this and black screen on iOS device.

我正在将我的应用程序从 xcode 运行到我的 iOS 设备,但我在 iOS 设备上看到了这个和黑屏。

Console text:

控制台文本:

dyld: Library not loaded: @rpath/libswiftCore.dylib
Referenced from: /private/var/mobile/Containers/Bundle/Application/10DB2FE8-EF09-4857-B4AC-0DB2E4419D6F/App-Name.app/App-Name           
Reason: image not found        
(lldb)

Screenshot added

添加了截图

回答by Amro Shafie

Try adding the following line to Runpath Search Pathsof your target.

尝试将以下行添加到目标的Runpath Search Paths

@executable_path/Frameworks

your_target-> Build Settings -> Linking -> Runpath Search Paths

your_target-> 构建设置 -> 链接 ->运行路径搜索路径

回答by zoruc

I had this same issue. I ended up adding the framework in the following locations:

我有同样的问题。我最终在以下位置添加了框架:

  1. General > Embedded Binaries
  2. General > Linked Frameworks and Libraries
  3. Build Phases > Link Binaries with Libraries
  1. General > Embedded Binaries
  2. General > Linked Frameworks and Libraries
  3. Build Phases > Link Binaries with Libraries

The embedded binariesseemed to be the key for me.

嵌入式二进制文件似乎是我的关键。

回答by Vitaliy Gozhenko

For me helps adding @executable_path/Frameworksto the projectRunpath Search Paths, not target. enter image description hereyour_project -> Build Settings -> Linking -> Runpath Search Paths

对我来说帮助添加@executable_path/Frameworks项目运行路径搜索路径,而不是目标。 在此处输入图片说明your_project -> 构建设置 -> 链接 -> 运行路径搜索路径

回答by ex3ndr

None of the other solutions helped me, but everything was fixed by deleting Xcode's Derived Datadirectory.

其他解决方案都没有帮助我,但是通过删除 Xcode 的派生数据目录来解决所有问题。

回答by user2077469

Oh yes. I've faced with that problem spending hours on solution. You may try to set "Always Embed Swift Standard Libraries" to "Yes" under your Build Settings > Build Options

哦是的。我遇到过这个问题,花费数小时来解决。您可以尝试在 Build Settings > Build Options 下将“Always Embed Swift Standard Libraries”设置为“Yes”

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

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

(don't forget to shift+cmd+K your project after)

(不要忘记 shift+cmd+K 你的项目之后)

回答by Justin Domnitz

I had to switch 'Embedded Content Contains Swift Code' to 'Yes' to get my Obj-C app to work after updating the Obj-C embedded framework with a Swift object.

在使用 Swift 对象更新 Obj-C 嵌入式框架后,我必须将“嵌入式内容包含 Swift 代码”切换为“是”才能使我的 Obj-C 应用程序正常工作。

回答by Islam Magdy

In the Framework Target (not the app target), go to Build Settings > Build Options > Always Embed Standard Swift Libraries to YES.

在框架目标(不是应用程序目标)中,转到构建设置 > 构建选项 > 始终嵌入标准 Swift 库到 YES。

This solved the issue for me!

这为我解决了这个问题!

回答by Santa Claus

I had this error in a command line project (Xcode 10.2 and macOS 10.14.3)

我在命令行项目(Xcode 10.2 和 macOS 10.14.3)中遇到了这个错误

The solution was to update to macOS 10.14.4

解决方案是更新到 macOS 10.14.4

Swift command line projects won't run on macOS 10.14.3 and earlier unless you install the Swift 5 Runtime Support for Command Line Tools package. Without that package, Swift command line projects crash on launch with “dyld: Library not loaded” errors. (46824656)

除非您安装 Swift 5 Runtime Support for Command Line Tools 包,否则 Swift 命令行项目将无法在 macOS 10.14.3 及更早版本上运行。如果没有这个包,Swift 命令行项目在启动时会崩溃,并出现“dyld: Library not loaded”错误。(46824656)

From Swift 5 Release Notes for Xcode 10.2

来自Swift 5 Release Notes for Xcode 10.2

回答by Aashish1aug

In my case, This issue is coming in Objective-c project in which I am using a Swift framework (AirWatch SDK).

就我而言,此问题出现在我使用 Swift 框架(AirWatch SDK)的 Objective-c 项目中。

Solutions:I have resolved this issue with Xcode 9.3 and 11.0.1 iOS as mentioned bellow steps :

解决方案:我已经使用 Xcode 9.3 和 11.0.1 iOS 解决了这个问题,如下所述:

  1. Drag and drop your swift framework in your project and move in default Framework folder of your project.
  2. Then add them as Embedded binaries as shown in screenshot.
  3. Change your framework status from Requiredto Optionalas shown in screenshot. (Build Phases > Link Binary with Library)
  1. 将 swift 框架拖放到项目中,然后移动到项目的默认 Framework 文件夹中。
  2. 然后将它们添加为嵌入式二进制文件,如屏幕截图所示。
  3. 如屏幕截图所示,将您的框架状态从必需更改为可选。(构建阶段 > 将二进制文件与库链接)

enter image description here

在此处输入图片说明

  1. Set Always Embed Swift Standard Librariesto Yesin your build settings.

  2. Set Subpathand select destination as Frameworkfor your added framework in Build Phases> Embed frameworks as shown in screenshot. enter image description here

  1. 设置总是嵌入斯威夫特标准库在您的构建设置。

  2. 如屏幕截图所示,在 Build Phases> Embed frameworks 中设置Subpath并为您添加的框架选择目标作为框架在此处输入图片说明

Hope it will help someone.

希望它会帮助某人。

回答by Mihail Salari

I fixed by deleting all from Xcode Derived Data directory:

我通过从 Xcode Derived Data 目录中删除所有内容来修复:

~/Library/Developer/Xcode/DerivedData

〜/图书馆/开发人员/Xcode/DerivedData

Good luck all!

祝大家好运!