Ios 向podsec文件添加一个ruby脚本

Ios 向podsec文件添加一个ruby脚本,ios,cocoapods,Ios,Cocoapods,我目前正在尝试创建一个依赖于外部模块的框架 该模块可以通过pod文件中的以下脚本添加: flutter_application_path = './flutter_embedding' eval(File.read(File.join(flutter_application_path, '.ios', 'Flutter', 'podhelper.rb')), binding) (您可以阅读有关此实现的更多信息 如果我运行它,这可以正常工作,但是,当运行pod spec lint时,我得到以下错

我目前正在尝试创建一个依赖于外部模块的
框架

该模块可以通过
pod文件中的以下脚本添加:

flutter_application_path = './flutter_embedding'
eval(File.read(File.join(flutter_application_path, '.ios', 'Flutter', 'podhelper.rb')), binding)
(您可以阅读有关此实现的更多信息

如果我运行它,这可以正常工作,但是,当运行
pod spec lint
时,我得到以下错误:

-错误|[iOS]xcodebuild:flatteriosframework/flatter_iOS_framework/AppDelegate.swift:10:8:错误:没有此类模块“flatter”

如果我正常运行项目,则不会发生此错误

所以问题是,我该怎么做才能在
podspec
文件中包含这个由脚本添加的外部模块

如果有帮助,上面代码段中使用的脚本如下所示:

def parse_KV_文件(文件,分隔符='='))
file\u abs\u path=file.expand\u path(文件)
如果!File.exists?文件路径
返回[];
结束
pods_数组=[]
跳过行开始符号=[“#”,“/”]
foreach(File_abs_path){行|
下一步如果跳过|行(开始)(符号|行=~/^\s*#{symbol}/}
plugin=line.split(pattern=separator)
如果plugin.length==2
podname=插件[0].strip()
path=插件[1].strip()
podpath=File.expand_path(“#{path}”,File_abs_path)
push({:name=>podname,:path=>podpath});
其他的
放置“无效的插件规范:#{line}”
结束
}
返回吊舱数组
结束
def颤振_根部(f)
生成的\u xcode\u build\u设置=解析\u KV\u文件(file.join(f,file.join('.ios',flatter',generated.xcconfig'))
如果生成的\u xcode\u build\u settings.empty?
puts“Generated.xcconfig必须存在。请确保在#{f}中执行'flatter packages get'
出口
结束
生成的代码生成设置.map{p|
如果p[:name]=“颤振根”
返回p[:路径]
结束
}
结束
#如果没有指定,则假定它位于该脚本目录的上两级。
flatter_应用程序_路径| |=File.join(uuu dir_uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu
framework\u dir=File.join(flatter\u应用程序路径,.ios,'flatter')
engine\u dir=File.join(framework\u dir,'engine')
如果!File.exist?(引擎目录)
#如果xcode后端脚本尚未运行,请复制调试引擎以使其具有可链接的对象。
debug\u framework\u dir=File.join(flatter\u根目录(flatter\u应用程序路径),'bin','cache','artifacts','engine','ios')
FileUtils.mkdir\u p(引擎目录)
FileUtils.cp\r(File.join(debug\u framework\u dir,'flatter.framework')、engine\u dir)
cp(File.join(debug\u framework\u dir,'flatter.podspec')、engine\u dir)
结束
吊舱‘颤振’,:路径=>发动机方向
pod'flatterpluginregistrant',:path=>File.join(framework\u dir'flatterpluginregistrant')
symlinks_dir=File.join(framework_dir,'.symlinks')
FileUtils.mkdir\u p(符号链接\u dir)
plugin_pods=parse_KV_文件(file.join(flatter_应用程序路径,'.flatter plugins'))
plugin_pods.map{r|
symlink=File.join(symlinks\u dir,r[:name])
FileUtils.rm\u f(符号链接)
文件.symlink(r[:path],symlink)
pod r[:name],:path=>File.join(符号链接,'ios')
}
#确保ENABLE_BITCODE设置为NO,将#include添加到Generated.xcconfig,然后
#将运行脚本添加到构建阶段。
安装后的do安装程序|
installer.pods_project.targets.each do| target|
target.build|u configurations.each do| config|
config.build\u设置['ENABLE\u BITCODE']='NO'
config.build_设置['CLANG_WARN_DIRECT_OBJC_ISA_USAGE']=“否”
下一步,如果config.base\u configuration\u reference==nil
xcconfig\u path=config.base\u configuration\u reference.real\u path
打开(xconfig_路径,'a+')do|文件|
file.puts“#include\”{file.realpath(file.join(framework_dir,'Generated.xcconfig'))}”
结束
结束
结束
结束

在进一步检查文件和目录后,我发现实际上它正在添加两个新的pod,
flatter
flatterpluginregistrant
,我可以添加它们,而不必使用脚本即可执行
PodFile