0%

libwebp Pod超时处理

反馈请联系hertz@hertzwang.com,谢谢

业务中需要支持WebP图片,然后在Pod时提示超时,解决思路是先fork一份libwebp项目,然后添加libwebp.podspec文件,最后在Podfile中指定源

Fork项目

  1. 终端执行 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)
    
  2. 新建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

注意:

  1. libwebp.podspec中的信息源于libwebp.podspec.json文件
  2. s.source中的git为fork后的新地址
  3. 由于使用的是tag,所以需要新建名为s.version对应的tag
  4. s.source_files这块的写法是只用到了webp

指定源

指定Git库及分支,在Podfile文件中添加如下:

1
pod 'libwebp', :git => 'https://example/libwebp.git', :branch => 'master'

其它

GIF vs APNG vs WebP