Unable to run swift scripts

Number:rdar://FB9293573 Date Originated:2021-07-08
Status:Open Resolved:
Product:MacOS Product Version:macOS 11.3 Big Sur
Classification:Security - App Sandbox Escape Reproducible:Yes
From app sandbox, we are unable to launch .swift scripts. In particular, main.swift with a header of "#!/usr/bin/swift". We get the error: `xcrun: error: cannot be used within an App Sandbox` At the same time, we are able to run other scripts with identical functionality such as .zsh scripts with a header of "#!/bin/zsh"

We would prefer to write our scripts in swift rather than zsh. Why are there specific restrictions on swift scripts? Note that all of the scripts are code-signed and included in the app bundle.

To reproduce:
1. Create an app with app sandbox enabled
2. Create a .swift script that is included in resources
3. Use Process (https://developer.apple.com/documentation/foundation/process/2890108-run) to launch the script
4. See that the console has error message and script does not start


Similar Issue Reported on Apple Forums


By developer.computers at July 8, 2021, 11:14 p.m. (reply...)

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!