反馈请联系hertz@hertzwang.com,谢谢
业务中需要支持WebP图片,然后在Pod时提示超时,解决思路是先fork一份libwebp项目,然后添加
libwebp.podspec
文件,最后在Podfile中指定源
Fork项目
终端执行
pod search libwebp
查看仓库地址,或使用Github上找到的https://github.com/webmproject/libwebp
-> libwebp (1.1.0) Library to encode and decode images in WebP format. pod 'libwebp', '~> 1.1.0' - Homepage: https://developers.google.com/speed/webp/ - Source: https://chromium.googlesource.com/webm/libwebp - Versions: 1.1.0, 1.1.0-rc2, 1.0.3, 1.0.2, 1.0.1, 1.0.0, 0.6.1, 0.6.0, 0.5.2, 0.5.1, 0.5.0, 0.4.4, 0.4.3, 0.4.2, 0.4.1 [trunk repo] - Subspecs: - libwebp/webp (1.1.0) - libwebp/demux (1.1.0) - libwebp/mux (1.1.0)
新建Git仓库并上传
添加 libwebp.podspec
在Git根目录新建文件libwebp.podspec
,格式参考Podspec Syntax Reference,大体如下:
Pod::Spec.new do |s|
s.name = 'libwebp'
s.version = '1.1.0'
s.summary = 'Library to encode and decode images in WebP format.'
s.description = <<-DESC
Library to encode and decode images in WebP format.
DESC
s.homepage = 'https://developers.google.com/speed/webp/'
s.license = { :type => 'BSD', :file => 'COPYING' }
s.author = { 'Google Inc.' => 'mail@google.com' }
s.source = { :git => 'https://example/libwebp.git', :tag => s.version.to_s }
s.compiler_flags = '-D_THREAD_SAFE'
s.requires_arc = false
s.platforms = { :ios => '6.0' }
s.pod_target_xcconfig = { "USER_HEADER_SEARCH_PATHS": "$(inherited) ${PODS_ROOT}/libwebp/ ${PODS_TARGET_SRCROOT}/" }
s.preserve_paths = 'src'
s.ios.deployment_target = '6.0'
s.source_files = 'src/webp/decode.h', 'src/webp/encode.h', 'src/webp/types.h', 'src/webp/mux_types.h', 'src/webp/format_constants.h', 'src/utils/*.{h,c}', 'src/dsp/*.{h,c}', 'src/dec/*.{h,c}', 'src/enc/*.{h,c}'
end
注意:
libwebp.podspec
中的信息源于libwebp.podspec.json
文件s.source
中的git
为fork后的新地址- 由于使用的是tag,所以需要新建名为
s.version
对应的tag s.source_files
这块的写法是只用到了webp
指定源
指定Git库及分支,在Podfile
文件中添加如下:
1 | pod 'libwebp', :git => 'https://example/libwebp.git', :branch => 'master' |