Cocoapods引入GPUImage2

1,569 阅读1分钟

前言

GPUImage2未提供pods方式加载,如果想使用这种方式需要自己写一个podspec文件进行链接。

方案

Pod::Spec.new do |s|
s.name     = 'GPUImage2'
s.version  = '0.1.0'
s.license  = 'BSD'
s.summary  = 'An open source iOS framework for GPU-based image and video processing.'
s.homepage = 'https://github.com/BradLarson/GPUImage2'
s.author   = { 'Brad Larson' => 'contact@sunsetlakesoftware.com' }

# This commit on that fork of GPUImage should contain just upgrades needed for Swift 4 compatibility. See https://github.com/BradLarson/GPUImage2/pull/212
# Replace with https://github.com/BradLarson/GPUImage2.git when merged
# into BradLarson's repository.
s.source   = { :git => 'https://github.com/andrewcampoli/GPUImage2', :commit => 'ffd7b5a64a20535980d4e9eb156fe2ecbe41fc6a' }

s.source_files = 'framework/Source/**/*.{swift}'
s.resources = 'framework/Source/Operations/Shaders/*.{fsh}'
s.requires_arc = true
s.xcconfig = { 'CLANG_MODULES_AUTOLINK' => 'YES', 'OTHER_SWIFT_FLAGS' => "$(inherited) -DGLES"}

s.ios.deployment_target = '8.0'
s.ios.exclude_files = 'framework/Source/Mac', 'framework/Source/Linux', 'framework/Source/Operations/Shaders/ConvertedShaders_GL.swift'
s.frameworks   = ['OpenGLES', 'CoreMedia', 'QuartzCore', 'AVFoundation']

end
  1. Podfile同文件夹下新建一个GPUImage2.podspec文件,文件代码如上所示。这里用的是最新一次release的一次commit

2.在Podfile中引入: pod 'GPUImage2', :podspec => './GPUImage2.podspec'

3.执行pod install

4.在项目文件中调用import GPUImage2

参考

For Swift 4, here's an update to @m1entus's local podspec