【问题标题】:Post_Install hook in .podspec file to change BUILD_LIBRARY_FOR_DISTRIBUTION to YES?.podspec 文件中的 Post_Install 挂钩将 BUILD_LIBRARY_FOR_DISTRIBUTION 更改为 YES?
【发布时间】:2021-06-13 21:14:42
【问题描述】:

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

在 Podfile 中,我有这个 post_install 钩子可以完成这项工作,但我想知道如何在 podspec 中执行此操作。

Pod 文件:

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

在 podspec 中,我试过这个:

spec.pod_target_xcconfig = { 'BUILD_LIBRARY_FOR_DISTRIBUTION' => 'YES' }

还有这个:

spec.xcconfig  =  = { 'BUILD_LIBRARY_FOR_DISTRIBUTION' => 'YES' }

但是对于框架中的所有依赖项,这些都没有改变它。

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

【问题讨论】:

  • 你解决了吗?告诉我
  • @ViktorVostrikov 未解决的问题,如果您找到任何解决方案,请告诉我。
  • 你找到解决办法了吗?

标签: ios swift cocoapods podspec


【解决方案1】:
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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-04-09
    • 1970-01-01
    • 1970-01-01
    • 2017-02-19
    • 1970-01-01
    • 1970-01-01
    • 2012-08-23
    相关资源
    最近更新 更多