最近遇到了两次次这个问题,都是Swift项目Pod添加库开启了use_frameworks!
,安装某些OC库时报错;花了好久时间解决,突然想起来之前OC项目安装Swift库也遇到了这个问题,但是之前没有记录,所以这次遇到时没有印象;这次记录下来,分享给大家:
<!--more-->
之前遇到的是OC代码安装ZLPhotoBrowser
的Swift库,开启了use_frameworks!
,和其他第三方库一起安装时,可以理解为,除了ZLPhotoBrowser
是动态库,其他的第三方库默认都使用static_framework
或者static_library
。
Pod文件末尾添加下面代码:
use_frameworks!
...
dynamic_frameworks = ['ZLPhotoBrowser']
pre_install do |installer|
installer.pod_targets.each do |pod|
if !dynamic_frameworks.include?(pod.name)
def pod.static_framework?;
true
end
def pod.build_type;
Pod::BuildType.static_library
end
end
end
end
这次是Swift代码安装Pod库,同样开启了use_frameworks!
,但是这里想要的是除了某些库使用static_framework
或者static_library
,其他库都默认使用use_frameworks!
。
所以Pod文件末尾添加的代码如下:
use_frameworks!
...
# 要使用OC的第三方库
static_frameworks = ['xxx', 'yyy']
pre_install do |installer|
installer.pod_targets.each do |pod|
# 注意这里和上面的不同
if static_frameworks.include?(pod.name)
def pod.static_framework?;
true
end
def pod.build_type;
Pod::BuildType.static_library
end
end
end
end
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。