ios - 如何使用 Cocoapods 制作基于两个静态库的动态框架(Swift)

标签 ios swift frameworks cocoapods podspec

我想制作一个动态框架,将两个第 3 方框架与静态库结合起来,然后将其作为 pod 添加到我的项目中。 这是他们的 podspec 文件

我试图将它们作为 s.dependency 添加到我的 podspec 文件中,但出现以下错误 Pods 错误 - 目标具有包含静态二进制文件的传递依赖项

试图将它们包含为 s.vendored_frameworks 但得到了关注 https://github.com/CocoaPods/CocoaPods/issues/6409并且无法使用给定的解决方案进行变通。

你能指导我如何处理它吗,稍后我会 发布一些测试项目来仔细研究这个问题。现在我有太多不同的测试项目不起作用,我什至不知道要发布到 Github 上来展示什么。

在我的大多数尝试中,我最终无法在我的框架 swift 文件中使用 Import IndoorsSDK/IndoorAtlas,因为 “没有这样的模块” 错误。

感谢任何帮助。

最佳答案

终于,我找到了解决方案。因此,如果有人遇到类似问题,我会在此处发布。

除了其他行,我的 podspec 文件包含以下内容

#// one library added as dependency, another as vendored_frameworks
#// because it lacks modulemap, so it was added manually to IndooRS framework
spec.dependency 'IndoorAtlas'
spec.vendored_frameworks = 'SKNavigation/Frameworks/IndoorsSDK.framework'

#// following lines fix linking issues so our pod would see dependency modules
spec.pod_target_xcconfig = {
    'FRAMEWORK_SEARCH_PATHS' => '$(inherited) $(SRCROOT)/**',
    'OTHER_LDFLAGS' => '$(inherited) -undefined dynamic_lookup'
  }

还有 modulemap,它被添加到缺少它的框架中

module IndoorsSDK [system] {
    header "Headers/IndoorsSDK.h"
    header "Headers/Indoors.h"
    export *
    link framework "CoreMotion"
    link framework "CoreBluetooth"
    link "c++"
}

最新一点,podfile 应该包含以下内容以隐藏传递依赖性错误。

pre_install do |installer|
    def installer.verify_no_static_framework_transitive_dependencies; end
end

可能就这些了。<​​/p>

关于ios - 如何使用 Cocoapods 制作基于两个静态库的动态框架(Swift),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43608066/

相关文章:

ios - 如何在 Swift 中使用 UIDatePicker?

ios - Swift/iOS - UITableView 与 UITableViewCell 不填充结果

ios - iOS 框架内使用的图像未在测试应用程序上加载

ios - 地理围栏无法正常工作

ios - 从 NSURLSessionDownloadDelegate 下载的数据存储在哪里?

ios - 如何使用 Firebase 进行多次观察?

swift - 游戏中心整合

swift - 用 cocoa swift 绘制

swift - 手动添加框架后缺少所需模块

ios - 如何管理我正在制作的框架与主应用程序之间的依赖项冲突?