如何使用Cocoapods基于两个静态库创建一个基于Swift的动态框架

5
我希望创建一个动态框架,将两个带有静态库的第三方框架集成,并将其作为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,因为出现"No such module"错误。
感激任何帮助。
1个回答

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'
  }

同时,这个框架还添加了 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

这可能就是全部内容了。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接