title: How to remove DT_TOOLCHAIN_DIR from LD_RUNPATH_SEARCH_PATHS via Podfile
body: <p>I'm trying to workaround a bug with Cocoapods (<a href="https://github.com/CocoaPods/CocoaPods/issues/10954#issuecomment-1214226181" rel="nofollow noreferrer">incorrect addition of LD_RUNPATH</a>)</p>
  <p>Rather than writing some other script to fix up the app and framework loader paths after I've built, I thought I'd just try to remove the offending incorrect path from the LD_RUNPATH_SEARCH_PATHS array, using a post_install. The goal is to end up with an xcode configuration that does not include the DT_TOOLCHAIN_DIR... in the LD_RUNPATH_SEARCH_PATHS.</p>
  <p>I can see the offending code <a href="https://github.com/CocoaPods/CocoaPods/blob/09977627209a9fc6e3e1e582237af8bc5141af5f/lib/cocoapods/target/build_settings.rb" rel="nofollow noreferrer">here</a> (line 362, method _ld_runpath_search_paths)</p>
  <pre><code>          paths &lt;&lt; '${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}' if uses_swift
  </code></pre>
  <p>but when I output the paths at post_install, that path with DT_TOOLCHAIN_DIR isn't in the list. This is what I'm doing in post_install:</p>
  <pre><code>remove_if_contains = [&quot;DT_TOOLCHAIN_DIR&quot;]
    targets_to_check = &quot;SWB Audio App&quot;
    pi.pods_project.targets.each do |target|
      if target.name.include? targets_to_check
        puts &quot;Checking #{target}&quot;
        target.build_configurations.each do |config|
          search_paths = config.build_settings['LD_RUNPATH_SEARCH_PATHS']
          unless search_paths.nil? || search_paths.empty?
            puts &quot; - checking  build config: #{config}&quot;
            remove_if_contains.each do |prefix|
              # Remove the entire prefix from LIBRARY_SEARCH_PATHS
              paths = search_paths.split(&quot; &quot;)
              puts &quot; - #{paths}&quot;
            end
          else
            puts &quot;#{config} doesnt contain LD_RUNPATH_SEARCH_PATHS. Has: #{config.build_settings.keys}&quot;
          end
        end
      end
    end
  </code></pre>
  <p>Here's the output:</p>
  <pre><code>Checking Pods-SWB Audio App
   - checking  build config: Debug
   - [[&quot;$(inherited)&quot;, &quot;@executable_path/../Frameworks&quot;, &quot;@loader_path/Frameworks&quot;]]
   - checking  build config: Release
   - [[&quot;$(inherited)&quot;, &quot;@executable_path/../Frameworks&quot;, &quot;@loader_path/Frameworks&quot;]]
  </code></pre>
  <p>And here's what is actually in the build configuration:</p>
  <pre><code>LD_RUNPATH_SEARCH_PATHS = $(inherited) /usr/lib/swift '@executable_path/../Frameworks' '@loader_path/Frameworks' &quot;${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}&quot; @loader_path/../Frameworks
  </code></pre>
  <p>I don't know enough about ruby/cocoapods atm to understand where im going wrong. or if post_install is the right place to be doing this.</p>
  <p>any tips?</p>