ios dyld:库未加载 cocoapods 0.37 和 Xcode 6.3

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

dyld: Library not loaded with cocoapods 0.37 and Xcode 6.3

iosxcode6cocoapods

提问by Jorge Revuelta

I've been reading all the issues about the error:

我一直在阅读有关错误的所有问题:

dyld: Library not loaded: @rpath/Bolts.framework/Bolts Referenced from: /private/var/mobile/Containers/Bundle/Application/1542F906-CCE1-4181-AC7C-B5E3EE50E7D7/eBikeMotion.app/eBikeMotion Reason: no suitable image found. Did find:

dyld: Library not loaded: @rpath/Bolts.framework/Bolts Referenced from: /private/var/mobile/Containers/Bundle/Application/1542F906-CCE1-4181-AC7C-B5E3EE50E7D7/eBikeMotion.app/eBikeMotion Reason: no suitable image found. Did find:

Which makes my application unable to run in a real device (but it runs without any problem in the simulator. Until certain point I thought that it was an issue with the frameworks I was installing, but after installing manually the original one that was throwing the error, Alamofire, and the next Framework throwing the error was the next one in alphabetical order (Bolts, as you can see in the code snippet) So I've reached the conclusion that is indeed CocoaPods which is producing these errors. I've got the last version (0.37) with a clean install, Iv'e tried to create a new project, I've tried all the proposed solutions to this issue without any luck, so I have to open an issue, with the hope that someone can help me.

这使我的应用程序无法在真实设备中运行(但它在模拟器中运行没有任何问题。直到某一时刻,我认为这是我正在安装的框架的问题,但在手动安装后,原来的框架抛出了错误、Alamofire 和下一个抛出错误的框架是按字母顺序排列的下一个(螺栓,正如您在代码片段中看到的那样)所以我得出的结论确实是 CocoaPods 产生了这些错误。我已经通过全新安装获得最新版本(0.37),我尝试创建一个新项目,我已经尝试了所有针对此问题的建议解决方案但没有任何运气,所以我必须打开一个问题,希望有人可以帮我。

Regards.

问候。

回答by Jorge Revuelta

After reinstalling the whole system and don't finding a solution, I've found that some of the Build Phases mandatory for CocoaPods to run properly were missing.

在重新安装整个系统并且没有找到解决方案后,我发现 CocoaPods 正常运行所必需的一些构建阶段丢失了。

The solution for this problem goes for the next steps:

此问题的解决方案用于以下步骤:

  1. Deintegrate the cocoapods project (you can install the tool with sudo gem install cocoapods-deintegrate).
  1. 分解 cocoapods 项目(您可以使用 安装该工具sudo gem install cocoapods-deintegrate)。

cocoapods-deintegrate on Github

cocoapods-在 Github 上解体

  1. Modify your Podfile:

    You should define your target linking with link_with 'ProjectName'.

    You should define the target for your pods: target 'ProjectName' do[pods here] end.

  2. Make an install with pod install

  3. After doing this, go to XCode and check the following settings:

    Into project settings, under "Configurations" check that in Debug and Release you've got a Configuration set named Pods-ProjectName.[debug|release]

    Into your target, under "Build Phases" you should have three new phases that should be named: Check Pods Manifest, Embed Pods Frameworksand Copy Pods Resources.

  4. Make a clean, then build, then run into your device.

  1. 修改你的 Podfile:

    您应该使用link_with 'ProjectName'.

    您应该为 pod 定义目标:target 'ProjectName' do[pods here] end

  2. 进行安装 pod install

  3. 执行此操作后,转到 XCode 并检查以下设置:

    进入项目设置,在“配置”下检查在调试和发布中你有一个名为的配置集 Pods-ProjectName.[debug|release]

    进入你的目标,在“Build Phases”下你应该有三个新的阶段,它们应该被命名为:Check Pods ManifestEmbed Pods FrameworksCopy Pods Resources

  4. 进行清理,然后构建,然后运行到您的设备中。

That's it.

就是这样。

回答by Suz

In my case, I followed the above answer by @Jorge, but it didn't resolve the problem. The exact error was a bit different because the missing file was @rpath Pods.framework/Pods. I finally resolved it with help from CocoaPods issue #3586:

就我而言,我遵循了@Jorge 的上述答案,但并没有解决问题。确切的错误有点不同,因为丢失的文件是@rpath Pods.framework/Pods. 我终于在 CocoaPods 问题 #3586 的帮助下解决了这个问题:

Go to target > General > Linked Frameworks and Libraries section set both Pods.framework and Pods_target.framework to Optional.

转到 target > General > Linked Frameworks and Libraries 部分,将 Pods.framework 和 Pods_target.framework 都设置为Optional.

Still trying to figure out exactly why.... this answer has some info: what-does-it-mean-to-weak-link-a-framework

仍在试图弄清楚为什么......这个答案有一些信息:what-does-it-mean-to-weak-link-a-framework

回答by Raphael

I had to fix two issues:

我必须解决两个问题:

  1. Go to each target then Build Phasesthen Link Binary With Librariesand select Pods.framework. Set it to Optional.

  2. Cocoapods did not create the needed run scripts for my second target. My first target had all scripts. The second not. So I copied all missing run scripts from the first to the second target. You need to tap on the small "+" sign on the top left, add a run script and paste the script from the other target. I've done that for Check Pods Manifest.lock, Copy Pods Resourcesand Embed Pods Frameworks.

  1. 去各个目标,然后Build PhasesLink Binary With Libraries选择Pods.framework。将其设置为Optional

  2. Cocoapods 没有为我的第二个目标创建所需的运行脚本。我的第一个目标拥有所有脚本。第二个没有。所以我将所有丢失的运行脚本从第一个目标复制到第二个目标。您需要点击左上角的小“+”号,添加一个运行脚本并粘贴来自另一个目标的脚本。我已经为Check Pods Manifest.lock,Copy Pods ResourcesEmbed Pods Frameworks.

Then it did run on the device. Finally.

然后它确实在设备上运行。最后。

回答by badeleux

Had same issue adding pods to WatchKit Extension. Linking main target with Watch app is not the best option at all. Found out that cocoapod 0.37.2 hasn't added 'Embed Pods Frameworks' script into build phase.

将 pod 添加到 WatchKit 扩展时遇到了同样的问题。将主要目标与 Watch 应用程序链接起来根本不是最佳选择。发现 cocoapod 0.37.2 没有将“Embed Pods Frameworks”脚本添加到构建阶段。

Script: "${SRCROOT}/Pods/Target Support Files/Pods-ExtensionName/Pods-ExtensionName-frameworks.sh"

脚本: "${SRCROOT}/Pods/Target Support Files/Pods-ExtensionName/Pods-ExtensionName-frameworks.sh"

回答by Siamaster

In order to have cocoapods generate the build phases Check Pods Manifest, Embed Pods Frameworks and Copy Pods Resources:

为了让 cocoapods 生成构建阶段,请检查 Pods Manifest、Embed Pods Frameworks 和 Copy Pods 资源:

1 - Go to build phases and remove any custom modifications. I had to remove everything under the Link Binary With Libraries phase.

1 - 进入构建阶段并删除任何自定义修改。我必须删除 Link Binary With Libraries 阶段下的所有内容。

2 - Do a pod deintegrate (Or just remove the files yourself)

2 - 做一个 pod deintegrate(或者自己删除文件)

3 - Run a new pod install

3 - 运行新的 pod 安装

This worked for me. Without the first step, it never did.

这对我有用。没有迈出第一步,它永远不会做到。

回答by Bhavesh Patel

To Resolve this you need to change status in Link Binary with Libraries in build phase for pod_projectName.framework and Bolt.framework

要解决此问题,您需要在 pod_projectName.framework 和 Bolt.framework 的构建阶段更改 Link Binary with Libraries 中的状态

I got the same error in my project.

我在我的项目中遇到了同样的错误。

get error in CommonCrypto.framework

在 CommonCrypto.framework 中得到错误

Resolved error by changing Required to Optional

通过将必需更改为可选来解决错误

回答by Dino Alves

The easiest thing to do would be to ensure that your Protobuf.framework is a dependency in your target's scheme inside the Build step.

最简单的方法是确保您的 Protobuf.framework 是构建步骤中目标方案的依赖项。

This tells Xcode to compile the Protobuf.framework created by your pod install/update whenever it builds your target.

这告诉 Xcode 在构建目标时编译由 pod install/update 创建的 Protobuf.framework。