title: How to access my app’s derived data folder itself?
body: <p>I’m in the middle of moving my iOS app’s Firebase dependency from CocoaPods to Swift Package Manager.</p>
  <p>Firebase’s Crashlytics requires a script to be executed while the app is building (using the Run Script build phase). Back in the CocoaPods days, I used to call the script the way <a href="https://firebase.google.com/docs/crashlytics/get-started" rel="noreferrer">documented by Google</a>: <code>&quot;${PODS_ROOT}/FirebaseCrashlytics/run&quot;</code>.</p>
  <p>After I’ve switched to SPM, Firebase files are no longer in <code>${PODS_ROOT}</code>, and there’s no such variable available at all. I know the file I need is now located in the <code>DerivedData</code> folder, specifically it’s at <code>~/Library/Developer/Xcode/DerivedData/MyApp-abcde/SourcePackages/checkouts/firebase-ios-sdk/Crashlytics/run</code>. The problem is, <strong>the <code>MyApp-abcde</code> folder is not easily referenced.</strong></p>
  <p><a href="https://medium.com/dev-genius/firebase-spm-xcode-12-bcefcef2bd6b" rel="noreferrer">A Medium post I found</a> suggested using the <code>${BUILD_DIR}</code> build variable (in regard to the example above, it would resolve to <code>&lt;…&gt;/MyApp-abcde/Build/Products</code>), and calling the <code>dirname</code> command to move up the directory hierarchy.</p>
  <p>This hack worked only for <em>running</em> the app. When I tried to <em>archive</em> it, <code>${BUILD_DIR}</code> resolved to another path, namely <code>&lt;…&gt;/MyApp-abcde/Build/Intermediates.noindex/ArchiveIntermediates/MyApp/BuildProductsPath</code>. I tried a few more build variables, such as <code>${SYMROOT}</code>, in place of <code>${BUILD_DIR}</code>, but they also produce different paths depending on the operation.</p>
  <p>So, here comes the question…</p>
  <p><strong>Is there a way to reliably reference my app’s derived data folder’s root</strong> (i.e. <code>~/Library/Developer/Xcode/DerivedData/MyApp-abcde</code>) <strong>using Xcode’s build variables?</strong></p>