ios - 椰子足 : Redefining preprocess macro using post install hook

标签 ios xcode cocoapods

我想更新我的 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 == "Pods-MyPod"
      target.build_configurations.each do |config|
        config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)', 'FEATURE=0']
      end
    end
  end
end

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

我做错了什么吗?

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

最佳答案

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

post_install do |installer_representation|
  installer_representation.pods_project.targets.each do |target|
    if target.name == "Pods-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/

相关文章:

ios - 长按 UITableViewCell 的下载选项

ios - 如何清除 Restkit 中 UITableView 的 NSFetchedResultsController 结果

ios - 在 iOS StoryBoard 中一次更改所有条形按钮项目的颜色

git - 我应该将 Pod 添加到 VCS 吗?

ios - 体系结构 armv7(FMDB) 的重复符号

ios - 使用 SceneDelegate 在 AppDelegate 中设置 UIWindow

ios - 如何在 `nm` 工具中搜索公共(public)或私有(private) API 以查找二进制 .ipa 中的所有库

xcode - swift 3 中的折线图

ios - 需要用我的临时配置文件重新签署 IPA 文件

ios - 如何使用 cocoa pod 的 Storyboard引用?