.podspec 文件中的 Post_Install 挂钩将 BUILD_LIBRARY_FOR_DISTRIBUTION 更改为 YES?

Muh*_*aza 7 ios cocoapods podspec swift

我有一个私有 Pod 框架,它有一些依赖项。我想更改BUILD_LIBRARY_FOR_DISTRIBUTION该框架中的所有依赖项。

在 Podfile 中,我有一个 post_install 钩子可以完成这项工作,但我想知道如何在 podspec 中做到这一点。

播客文件:

post_install do |installer|
  installer.pods_project.targets.each do |target|
   target.build_configurations.each do |config|
    config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
   end
  end
 end
Run Code Online (Sandbox Code Playgroud)

在 podspec 中,我尝试过:

spec.pod_target_xcconfig = { 'BUILD_LIBRARY_FOR_DISTRIBUTION' => 'YES' }
Run Code Online (Sandbox Code Playgroud)

和这个:

spec.xcconfig  =  = { 'BUILD_LIBRARY_FOR_DISTRIBUTION' => 'YES' }
Run Code Online (Sandbox Code Playgroud)

但这些都没有改变框架中的所有依赖项。

另外,在搜索时,我发现这个 https://guides.cocoapods.org/syntax/podspec.html#prepare_command可用于转换 post_install 挂钩。不幸的是,我不知道如何做。任何帮助,将不胜感激。提前致谢。

小智 -2

post_install do |installer|
 installer.pods_project.targets.each do |target|
  if ["MyFramework"].include? target.name
   target.build_configurations.each do |config|
    config.build_settings['BUILD_LIBRARY_FOR_DISTRIBUTION'] = 'YES'
   end
  end
 end
end
Run Code Online (Sandbox Code Playgroud)