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

San*_*der 5 frameworks ios cocoapods podspec swift

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

我尝试将它们添加到s.dependency我的 podspec 文件中,但出现以下错误 Pods error - target has transitive dependencies that include static binaries

试图将它们包括在内,s.vendored_frameworks但遵循https://github.com/CocoaPods/CocoaPods/issues/6409并且无法使用给定的解决方案进行解决。

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

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

感谢任何帮助。

San*_*der 3

最后,我找到了解决方案。因此,如果有人遇到类似的问题,我将其发布在这里。

我的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'
  }
Run Code Online (Sandbox Code Playgroud)

并且modulemap,它被添加到缺乏它的框架中

module IndoorsSDK [system] {
    header "Headers/IndoorsSDK.h"
    header "Headers/Indoors.h"
    export *
    link framework "CoreMotion"
    link framework "CoreBluetooth"
    link "c++"
}
Run Code Online (Sandbox Code Playgroud)

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

pre_install do |installer|
    def installer.verify_no_static_framework_transitive_dependencies; end
end
Run Code Online (Sandbox Code Playgroud)

这可能就是全部了。