私有库.podspec文件的配置大概如下
s.framework = "UIKit"
s.dependency 'Alamofire', '~> 4.7'
s.dependency 'MBProgressHUD', '~> 1.2.0'
使用私有库的时候报错
[!] The following Swift pods cannot yet be integrated as static libraries:
The Swift pod `xxxx` depends upon `MBProgressHUD`, which does not define modules.
To opt into those targets generating module maps (which is necessary to import them from Swift when building as static libraries),
you may set `use_modular_headers!` globally in your Podfile,
or specify `:modular_headers => true` for particular dependencies.
解决方法有三种
1)可以在Podfile文件的顶部加
use_frameworks! // 加这行
target 'xxxxxx' do
pod 'MBProgressHUD', '~> 1.2.0'
end
原理是把pod里面的库编译成frameworks
2)也可以在Podfile文件的顶部加
use_modular_headers! // 加这行
target 'xxxxxx' do
pod 'MBProgressHUD', '~> 1.2.0'
end
原理是把pod里面的库编译成Modular, 它是可以直接在Swift中 import 的,不需要再经过 bridging-header 的桥接
3.因为use_modular_headers!是把所有的pod库都编译成Modular,也可以只改一个库,Podfile文件的如下:
target 'xxxxxx' do
pod 'MBProgressHUD', '~> 1.2.0', :modular_headers => true
end