podSpec代码如下:
class MyCode
def recursionDirCreateSubSpace(path1,space,&block)
ignore = ['.','..','.xcodeproj','.xcworkspace','.xcassets','.lproj']
Dir.foreach(path1){
|file|
extname = File::extname(file)
if ignore.include?(file)
next
end
if ignore.include?(extname) && extname.length > 0
next
end
tmpPath = "#{path1}/#{file}"
if File::ftype(tmpPath) == "directory"
space.subspec file do |tmpS|
tmp_source_files = "#{tmpPath}/*.{h,m}"
tmpS.name = "#{file}"
p file
tmpS.source_files = tmp_source_files
#Proc 可以这么,无限调用block
#if tmpPro
# tmpPro.call(tmpPath,tmpS)
#end
block.call(tmpPath,tmpS)
recursionDirCreateSubSpace(tmpPath,tmpS,&block)
end
end
}
end
end
Pod::Spec.new do |s|
s.name = 'TestPodSpace'
s.version = '1.0'
s.summary = 'MSGeneral'
s.homepage = 'https://gitee.com/408477779/test-pod-space.git'
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { 'TestPodSpace' => 'TestPodSpace' }
s.source = { :git => 'https://gitee.com/408477779/test-pod-space.git',:submodules => true}
s.ios.deployment_target = '10.0'
s.source_files = 'testPodSpace/testPodSpace/*.{h,m}'
s.requires_arc = true
s.static_framework = true
#小细节,这个OTHER_LIBTOOLFLAGS ,podSpec只会认为这是个字符串,很难受
s.pod_target_xcconfig = {'OTHER_LDFLAGS'=>['$(inherited)','ObjC','-l"facexdet"','-l"facexlive"','-l"ssl"','${PODS_ROOT}/MSAIRecord/MSGeneral/MSGeneral/Vendor/SDK/MSStandardizedOCRSDK/MSStandardizedOCRSDK.a'],
'OTHER_LIBTOOLFLAGS'=>'$(inherited) -ObjC',
}
MyCode.new.recursionDirCreateSubSpace("testPodSpace/testPodSpace",s) do |tmpPath,subSpec|
p tmpPath
p subSpec
end
end
1.rebuy的回调的几种方式
1.1 yield
class MyCode
def recursionDirCreateSubSpace(path1,space)
if block_given?
yield(subPth,subSpec)
end
end
Pod::Spec.new do |s|
#....
MyCode.new.recursionDirCreateSubSpace("testPodSpace/testPodSpace",s) do |subPth,subSpec|
end
end
1.2Proc
class MyCode
def recursionDirCreateSubSpace(path1,space,proc)
if proc
proc.call(subPath,subSpec)
end
end
Pod::Spec.new do |s|
#....
tmpPro = Proc.new do |tmpPath,subSpec|
#更改subSpec的其他设置
p tmpPath
p subSpec.to_json
end
MyCode.new.recursionDirCreateSubSpace("testPodSpace/testPodSpace",s, tmpPro)
end
1.3block作为Proc的参数
这种基本属于Proc的
class MyCode
def recursionDirCreateSubSpace(path1,space,&block)
block.call(subPath,subSPec)
recursionDirCreateSubSpace(subPath, subSPec,&block)
end
end
Pod::Spec.new do |s|
s.name = 'TestPodSpace'
MyCode.new.recursionDirCreateSubSpace("testPodSpace/testPodSpace",s) do |tmpPath,subSpec|
p tmpPath
p subSpec
end
end
1.4用lambda
创建Proc
对象
此处不讲
recursionDirCreateSubSpace
是我编写的函数,最重要的就是这个函数。其他就是了解pod的设计思想即可。
demo:
https://gitee.com/408477779/test-pod-space.git
使用代码如下:
pod 'TestPodSpace', :git => 'https://gitee.com/408477779/test-pod-space.git'
or
pod('TestPodSpace', :git => 'https://gitee.com/408477779/test-pod-space.git')
如有需要包含其他文件更改source_files
匹配即可
网友评论