项目或其他无法识别 Pod 内的供应商框架 pods(Cocoapods/Cocoapods #3810)

Vendored framework inside of pod not recognized by project or other pods (Cocoapods/Cocoapods #3810)

在我的项目中,我引用了我公司使用的几个私有pods。其中一个 pods 称为 DKKit 依赖于我包含的另一个私有 pod,称为 BaseProKit。 BaseProKit 包含它在其 header 和实现文件中引用的 3 个框架,我认为它们被认为是 vendored_frameworks。在 BaseProKit 的现有 header 文件中,通过像 #import <PPCommon/PPCommon> 这样的导入引用了这些框架,这些框架在仅依赖 BaseProKit pod 进行编译时(通常)工作得很好。但是,当包含 DKKit 时,DKKit 在导入时会查找一个 header 别名 (BaseProKit.h),其中包含上述导入。然而,在 DKKit 的上下文中,DKKit pod 似乎不知道 PPCommon 框架的存在,它只看到它的 header 文件的别名通过 Pods-BaseProKit 引用。因此,对 <PPCommon/ANYTHING> 的任何和所有引用都会产生编译错误(未找到),到目前为止我唯一能弄清楚的方法就是通过 #import "PPCommon.h" 进行引用,这需要我调整整个 BaseProKit 项目中的所有导入,但感觉不对。

我收录了以下文件以供参考: BaseProKit 的 Podspec:

  s.name         = "BaseProKit"
  s.version      = "1.0.5"
  s.source_files = "BaseProKit/BaseProKit.h",
                   "BaseProKit/Data/*.{h,m}",
                   "BaseProKit/Sensor Calibration/*.{h,m}",
                   "BaseProKit/SP3D/BaseballSceneController/*.{h,m}",
                   "BaseProKit/SP3D/SceneElements/*.{h,m,hpp,cpp}",
                   "BaseProKit/SP3D/SceneEnvironment/*.{h,m}",
                   "BaseProKit/Third Party/DeviceModelDetector.{h,m}",
                   "BaseProKit/Third Party/SkyProKitEmptyMMFile.{h,mm}"
  s.resources = "BaseProKit/SatelliteLibrary/SatelliteLibrary.bundle","BaseProKit/SP3D/SP3DResources.bundle", "BaseProKit/SP3D/Models/Vertex Data/*"
  s.frameworks = "GLKit", "OpenGLES", "Foundation", "UIKit", "Accelerate", "PPCommon", "SatelliteLibrary", "SP3D"
  s.library = 'c++'
  s.prefix_header_file = "BaseProKit/BaseProKit-Prefix.pch"
  # s.public_header_files = "BaseProKit/PPCommon/PPCommon.framework/Headers/*.h", "BaseProKit/SatelliteLibrary/SatelliteLibrary.framework/Headers/*.h", "BaseProKit/SP3D/SP3D.framework/Headers/*.h"

  s.vendored_frameworks = "BaseProKit/PPCommon/PPCommon.framework",
                          "BaseProKit/SatelliteLibrary/SatelliteLibrary.framework",
                          "BaseProKit/SP3D/SP3D.framework"

DKKit 的 Podspec:

    s.name          = "DKKit"
    s.version       = "1.0.0"

    s.source_files  = 'DKKit/**/*.{h,m}'
    s.resources = 'DKKit/**/*.xcdatamodeld'
    s.dependency 'PromiseKit/Promise', '~> 1.3.0'
    s.dependency 'MBProgressHUD', '~> 0.9.1'
    s.prefix_header_contents = '#import "NSDictionary+Merge.h"'
    s.frameworks = 'CoreData'

    s.dependency 'BaseProKit', '~> 1.0.5'
    s.dependency 'SwingAnalysisKit', '~> 1.0.0'

我项目的 Podfile:

pod 'SwingAnalysisKit', :git => "https://swing-analysis-kit-URL", :branch => "develop"
pod 'BaseProKit', :git => "https://base-pro-kit-URL", :branch => "develop"
pod 'DKKit', :git => "https://DKKit-URL", :branch => "develop"

在我的两个 podspec 文件(尤其是 BaseProKit 的文件)中,我是否可以做一些不同的事情来确保这些框架可以被引用 作为框架(而不仅仅是他们的 header 文件)在 Pod 本身之外?

也将此作为问题复制到 Cocoapods/Cocoapods 存储库: https://github.com/CocoaPods/CocoaPods/issues/3810

在 CocoaPods 存储库中提出了许多与此相关的问题 - 例如,1824, 3161。我相信它已在 0.38.0.beta.1 -

中修复

Added recursive support to the public headers of vendored frameworks that are automatically linked in the sandbox. This fixes and issue for framework header directories that contain sub-directories. Todd Casey #3161

Public headers of vendored frameworks are now automatically linked in the sandbox. That allows transitive inclusion of headers from other pods. Vincent Isambart #3161

来源:Changelog