OGeek|极客世界-中国程序员成长平台

标题: ios - 椰子足 : Redefining preprocess macro using post install hook [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-13 10:19
标题: ios - 椰子足 : Redefining preprocess macro using post install hook

我想更新我的 pod 以允许用户激活/停用某项功能。

为此,我在我的 podspec 中添加了一个预处理器宏:

s.xcconfig         = { 'GCC_PREPROCESSOR_DEFINITIONS' => 'FEATURE=1' }

现在,对于用户来说,正确的做法(据我所知)应该是在 podfile 中使用安装后 Hook 来更改 FEATURE

post_install do |installer_representation|
  installer_representation.project.targets.each do |target|
    if target.name == "ods-MyPod"
      target.build_configurations.each do |config|
        config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)', 'FEATURE=0']
      end
    end
  end
end

但它根本没有做任何事情...... FEATURE 值仍然是 1

我做错了什么吗?

编辑: 我确实看过这个 answer , 但它没有帮助。



Best Answer-推荐答案


最后,我找到了一个可用的版本。

post_install do |installer_representation|
  installer_representation.pods_project.targets.each do |target|
    if target.name == "ods-MyPod"
      target.build_configurations.each do |config|
      config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = ['COCOAPODS=1', 'FEATURE=0']
      end
    end
  end
end

关于ios - 椰子足 : Redefining preprocess macro using post install hook,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28763194/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4