How to use OTHER_SWIFT_FLAGS in a Pod
<p>Has anybody tried to use build configuration flags in a Swift based Pod? I am trying to use a <a href="https://guides.cocoapods.org/syntax/podfile.html#post_install" rel="nofollow noreferrer">post_install</a> hook to add "OTHER_SWIFT_FLAGS" to a private Swift pod that I'm working on. Basically, I want to be able to do something like <code>#if DEV #elseif QA #else #endif</code> to change endpoints based on the target that I'm using. The project I'm integrating the pod with also uses DEV &amp; QA flags which work fine with corresponding DEV &amp; QA targets.</p>

<p>Here is a post_install hook that I came up using help from other similar posts:</p>

<pre><code>post_install do |installer|
    installer.pods_project.targets.each do |target|
        if target.name == 'Pods-Test-QA'
            puts "Found #{target.name}. Adding Swift Flag..."
            target.build_configurations.each do |config|
                puts "Configuration: #{config}"
                config.build_settings['OTHER_SWIFT_FLAGS'] ||= ['$(inherited)']
                config.build_settings['OTHER_SWIFT_FLAGS'] &lt;&lt; '-DQA'
                puts "#{config.build_settings['OTHER_SWIFT_FLAGS'].inspect}"
            end
        end
        if target.name == 'Pods-Test-DEV'
            puts "Found #{target.name}. Adding Swift Flag..."
            target.build_configurations.each do |config|
                puts "Configuration: #{config}"
                config.build_settings['OTHER_SWIFT_FLAGS'] ||= ['$(inherited)']
                config.build_settings['OTHER_SWIFT_FLAGS'] &lt;&lt; '-DDEV'
                puts "#{config.build_settings['OTHER_SWIFT_FLAGS'].inspect}"
            end
        end
    end
end
</code></pre>

<p>After running <code>pod install</code> the post_install successfully adds the flags as shown in the image below for Pods-Test-QA &amp; Pods-Test-DEV.</p>

<p><a href="https://i.stack.imgur.com/tXDjh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tXDjh.png" alt="enter image description here"></a></p>

<p>However, when I run the project using QA or DEV targets and use the following flags it always hits PROD:</p>

<pre><code>#if DEV
    print("DEV ENVIRONMENT")
#elseif QA
    print("QA ENVIRONMENT")
#else
    print("PROD ENVIRONMENT")
#endif
</code></pre>

<p>Is there something I'm missing?
Also, for some reason <code>Pods-Test-QA.debug.xcconfig</code> &amp; <code>DEV</code> don't seem to be updated with the flags I've added. Does anyone have any idea why it's not updating in the .xcconfig files?</p>

<pre><code>OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS"
</code></pre>

<p>Any help would be appreciated. Thanks in advance. </p>

<p>Using:</p>

<ul>
<li>cocoapods (1.0.1)</li>
<li>Xcode 7.3.1</li>
</ul>