.podspec文件

时间:2018-05-24 12:40:31

标签: ios xcode cocoapods

您好我有私人pod框架,我正在使用,直到现在它不是问题,因为在pod文件中我可以编辑SWIFT_OPTIMIZATION_LEVEL,如:

post_install do |installer|
    installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
            if (target.name == "MyLib")
                config.build_settings['SWIFT_OPTIMIZATION_LEVEL'] = '-Onone'
            end
        end
    end
end

但现在我想在我的另一个pod中使用此pod作为依赖项,所以在.podspec文件中我有

s.dependency 'MyLib', '~> 1.0'

所以我不能在post_install Podfile中这样做,因为它不存在。我试着这样做

prepare = <<-PREPARECOMMAND
ruby SWIFT_OPTIMALIZATION.rb
PREPARECOMMAND
s.prepare_command = prepare

但是它一直运行到最后并且最终它没有改变。我也尝试在

中运行它
s.script_phase

它可以工作,但只有在第一次失败后,在第一次构建时,它会更改优化并在第二次构建时取消。有没有办法将安装后挂钩添加到podspec?

1 个答案:

答案 0 :(得分:0)

s.pod_target_xcconfig = { 'SWIFT_OPTIMIZATION_LEVEL' => '-Onone' }