Xcode10-Dyld:未为库中安装的Pod加载库 [英] Xcode10 - dyld: Library not loaded for pod installed in framework

查看:222
本文介绍了Xcode10-Dyld:未为库中安装的Pod加载库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有目标框架的项目.

I have a project with target frameworks.

  • MainAppTarget
  • FrameworkA

FrameworkA是唯一使用特定pod的对象,因此在我的pod文件中,我有类似的东西

FrameworkA is the only one to use a certain pod, hence in my pod file I have something like

target 'MainAppTarget' do
    ...
end

target 'FrameworkA' do
    pod 'PodA'
end

构建成功没有问题,但是当我在模拟器上运行该应用时,该应用立即崩溃并显示以下错误消息:

the build succeeds with no problem, but when I run the app on a simulator the app crashes immediately with the following error message:

dyld: Library not loaded: @rpath/PodA.framework/PodA
  Referenced from: .../Build/Products/Development-iphonesimulator/FrameworkA.framework/FrameworkA
  Reason: image not found

我尝试了所有常见的可疑事件(删除派生数据,清除数据,pod解集成……),到目前为止没有任何效果.

I tried all the usual suspects (delete derived data, clean, pod deintegrate...) nothing worked so far.

您知道为什么会发生这种情况,以及如何使它工作而不必在两个目标上都必须安装所有吊舱吗?

Any idea why this would happen, and how I can make it work without having to install all the pods necessarily on both targets?

该应用程序在Swift 4.2中.

The app is in Swift 4.2.

推荐答案

从您的错误消息中,应该检查一些事情.

From your error message, there are a few things that should be checked.

dyld: Library not loaded: @rpath/PodA.framework/PodA
  Referenced from: .../Build/Products/Development-iphonesimulator/FrameworkA.framework/FrameworkA
  Reason: image not found

似乎很奇怪的第一件事是,正在加载的框架(FrameworkA.framework)的路径未嵌入应用程序内.检查MainAppTarget的常规"选项卡,并确保该框架出现在嵌入式​​二进制文件"和链接的框架和库"部分中.

The first thing that seems odd is that the path for the framework that is being loaded (FrameworkA.framework) is not embedded inside an app. Check the "General" tab of the MainAppTarget and make sure the framework is appearing in the "Embedded Binaries" and "Linked Frameworks and Libraries" sections.

第二,@rpathrunpath搜索路径列表的简写,它告诉dyld在哪里寻找所需的库.

Second, @rpath is a shorthand for the runpath search path list, which tells dyld where to look for needed libraries.

这是Github上的一个示例项目,其主应用程序使用一个Cocoapod,而主应用程序所依赖的动态框架则使用不同的Cocoapod:

Here's an example project on Github with a main app that uses one Cocoapod, and a dynamic framework that the main app depends on that uses a different Cocoapod: https://github.com/dtweston/FrameworkPodTest

构建设置,您应该检查所有涉及的目标(包括Pods项目构建的框架目标):

Build settings that you should check on all of the targets that are involved (including the framework targets built by the Pods project):

  • 运行路径搜索路径(LD_RUNPATH_SEARCH_PATHS)
    • 在示例项目中,这些值由cocoapod确定,但是每个值都设置为$(inherited) @executable_path/Frameworks @loader_path/Frameworks
    • Runpath Search Paths (LD_RUNPATH_SEARCH_PATHS)
      • In the example project, these are determined by the cocoapod, but each one is set to $(inherited) @executable_path/Frameworks @loader_path/Frameworks
      • 在示例项目中,这与默认的$(DYLIB_INSTALL_NAME_BASE:standardizepath)/$(EXECUTABLE_PATH)
      • 相同.
      • In the example project, this is unchanged from the default $(DYLIB_INSTALL_NAME_BASE:standardizepath)/$(EXECUTABLE_PATH)
      • 在示例项目中,设置为@rpath(同样由Cocoapod确定)
      • In the example project, set to @rpath (again determined by the Cocoapod)

      下面是构建的应用程序捆绑的屏幕截图,显示了其布局:

      Here's a screenshot of the built application bundle showing how it's laid out:

      您可以使用otool获取有关xcodebuild如何组装应用程序的信息.

      You can use otool to get information about how the application is assembled by xcodebuild.

      这是主要的应用二进制文件:

      Here's the main app binary:

      otool -L FrameworkPodTest
      FrameworkPodTest:
          @rpath/KeychainSwift.framework/KeychainSwift (compatibility version 1.0.0, current version 1.0.0)
          @rpath/Lottie.framework/Lottie (compatibility version 1.0.0, current version 1.0.0)
          /System/Library/Frameworks/UIKit.framework/UIKit (compatibility version 1.0.0, current version 61000.0.0)
          @rpath/Framework.framework/Framework (compatibility version 1.0.0, current version 1.0.0)
          /System/Library/Frameworks/Foundation.framework/Foundation (compatibility version 300.0.0, current version 1560.10.0)
          /usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
          /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.200.5)
          /System/Library/Frameworks/CoreGraphics.framework/CoreGraphics (compatibility version 64.0.0, current version 1245.9.2)
      ...
      

      以及框架二进制文件:

      otool -L Frameworks/Framework.framework/Framework
      Frameworks/Framework.framework/Framework:
          @rpath/Framework.framework/Framework (compatibility version 1.0.0, current version 1.0.0)
          @rpath/KeychainSwift.framework/KeychainSwift (compatibility version 1.0.0, current version 1.0.0)
          /System/Library/Frameworks/Foundation.framework/Foundation (compatibility version 300.0.0, current version 1560.10.0)
          /usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
          /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.200.5)
          @rpath/libswiftCore.dylib (compatibility version 1.0.0, current version 1000.11.42)
          @rpath/libswiftCoreFoundation.dylib (compatibility version 1.0.0, current version 1000.11.42)
      ...
      

      这篇关于Xcode10-Dyld:未为库中安装的Pod加载库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆