ios - 椰子足 : Redefining preprocess macro using post install hook
<p><p>我想更新我的 pod 以允许用户激活/停用某项功能。</p>
<p>为此,我在我的 <code>podspec</code> 中添加了一个预处理器宏:</p>
<pre><code>s.xcconfig = { 'GCC_PREPROCESSOR_DEFINITIONS' => 'FEATURE=1' }
</code></pre>
<p>现在,对于用户来说,正确的做法(据我所知)应该是在 <code>podfile</code> 中使用安装后 Hook 来更改 <code>FEATURE</的定义</code></p>
<pre><code>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
</code></pre>
<p>但它根本没有做任何事情...... <code>FEATURE</code> 值仍然是 1</p>
<p>我做错了什么吗?</p>
<p>编辑:
我确实看过这个 <a href="https://stackoverflow.com/questions/27133993/why-isnt-my-cocoapods-post-install-hook-updating-my-preprocessor-macros" rel="noreferrer noopener nofollow">answer</a> , 但它没有帮助。</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>最后,我找到了一个可用的版本。</p>
<pre><code>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
</code></pre></p>
<p style="font-size: 20px;">关于ios - 椰子足 : Redefining preprocess macro using post install hook,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/28763194/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/28763194/
</a>
</p>
页:
[1]