iOS AppExtension 引入第三方库

第一种方式,在Project-Info中修改Configurations,如图:


屏幕快照 2019-11-04 上午9.59.09.png

这样修改完成后在扩展中引入第三方库是否成功,打包测试一下是否能通过。
如果不行的话,就在Podfile文件中,引用第三方库。APP Extension和主APP引入第三方库的写法一样:
target "Extension名称" do
pod 'AFNetWorking'
end
如果类库与主项目是重复的,那可以将这一段包含在主项目中间,如果是单独引用的,可以与主项目分开写。
执行pod install
查看项目是否有以下错误:
1 引入第三方库报错:“ 'sharedApplication' is unavailable: not available on iOS (App Extension) - Use view controller based solutions where appropriate instead.”
打开终端,修改podfile,(vim Podfile)

post_install do |installer_representation|
installer_representation.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['APPLICATION_EXTENSION_API_ONLY'] = 'NO'
end
end
end

这段代码相当于修改工程中的


屏幕快照 2019-11-04 上午10.14.42.png

执行pod install
下图是我的实际项目中运用


屏幕快照 2019-11-04 上午9.38.54.png

2 打包遇到错误:bitcode bundle could not be generated
将对应target的Bitcode属性设置为NO


屏幕快照 2019-11-04 上午9.56.38.png

打包看一下是否成功。实际运用中我遇到的就是这些问题,其他问题欢迎补充,一起学习。

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容