title: XCode: Running a build script in -x86_64 while building for arm64 on macOS
body: <p>I am moving my app to arm64 on macOS12 Montery. While rebuilding its frameworks with arm64 worked fine so far i have some extend scripts in it that need to be compiled from JS to JSX before packing it to the app bundle. There's a Visual Studio Code plugin doing that for me (Extendscript debugger).</p>
  <p>Therefore i have added a script phase with this script</p>
  <pre><code>node &quot;$HOME/.vscode/extensions/adobe.extendscript-debug-1.1.2/public-scripts/exportToJSX.js&quot; -f -n &quot;$PROJECT_DIR/indesignagent/Javascript&quot;
  </code></pre>
  <p>It works fine on -x86_64 but fails on arm64 because the plugin itself isn't optimized yet for arm64 and XCode seems to execute it with /bin/sh on arm64 arch</p>
  <p>I found a manual solution i currently work with, but its just not as satisfying as an automated process:
  I open the terminal with rosetta mode and call the above command and it works through, then i build my app without that script phase.</p>
  <p>I'd like to know: Is there any way to execute a script phase/bash script with -x86_64.</p>
  <p>I already tried solutions mentioned here in the script phase: <a href="https://medium.com/swlh/run-x86-terminal-apps-like-homebrew-on-your-new-m1-mac-73bdc9b0f343" rel="nofollow noreferrer">https://medium.com/swlh/run-x86-terminal-apps-like-homebrew-on-your-new-m1-mac-73bdc9b0f343</a></p>
  <pre><code>arch -x86_64 /bin/zsh -c &quot;$(node ~/.vscode/extensions/adobe.extendscript-debug-1.1.2/public-scripts/exportToJSX.js -f -n ~/workfolder/myapp-arm/indesignagent/Javascript)&quot;
  </code></pre>
  <p>I think this won't work because XCode sets the interpreter in the UI here and i didn't find any way to prefix it with the architecture mentioned in the above linked solution
  <a href="https://i.stack.imgur.com/VpkZc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VpkZc.png" alt="enter image description here" /></a></p>
  <p>Any help appreciated</p>