Here is a simple swift script:
#!/usr/bin/env xcrun swift import Foundation let task = NSTask() task.launchPath = \"/bin/echo\" task.arguments = [\"farg1\", \"
When building for iOS the implicit SDK for xcrun is the iOS SDK, so you have the change it to the Mac OS X SDK with a command line parameter. Change the first line in your script to:
#!/usr/bin/env xcrun --sdk macosx swift