Can I create a Cocoa app that is only a Swift script?

I want the entire code for my entire Mac app to look like this .swift script:

#!/path/to/swift
import Cocoa
// The rest of my entire Mac app.

Because we don't yet have binary stability, I guess I'd have to put the swift binary (which runs the above .swift script) and a bunch of .dylibs into the Mac .app bundle somehow.

Is this possible to do and if so, how?

Why do you want to do this?
What to you mean by “binary stability?”
Why not use Xcode to build an application using the swift compiler?

···

On Jun 20, 2017, at 10:34 AM, tuuranton--- via swift-users <swift-users@swift.org> wrote:

I want the entire code for my entire Mac app to look like this .swift script:

#!/path/to/swift

import Cocoa

// The rest of my entire Mac app.

Because we don't yet have binary stability, I guess I'd have to put the swift binary (which runs the above .swift script) and a bunch of .dylibs into the Mac .app bundle somehow.

Is this possible to do and if so, how?

_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

It is not. The first problem is that there is no value of "/path/to/swift" that will work everywhere.

···

On Jun 20, 2017, at 7:34 AM, tuuranton--- via swift-users <swift-users@swift.org> wrote:

I want the entire code for my entire Mac app to look like this .swift script:

#!/path/to/swift

import Cocoa

// The rest of my entire Mac app.

Because we don't yet have binary stability, I guess I'd have to put the swift binary (which runs the above .swift script) and a bunch of .dylibs into the Mac .app bundle somehow.

Is this possible to do and if so, how?

--
Greg Parker gparker@apple.com <mailto:gparker@apple.com> Runtime Wrangler

It is not. The first problem is that there is no> value of "/path/to/swift" that will work everywhere.

Makes sense, but I guess one day macOS will ship with swift in a standard location like /usr/bin/swift so that would no longer be a problem.

Out of curiosity, what are the some of the other problems?

It gets distributed as part of Xcode (which is free, but not preloaded on anything) or as a download from swift.org or GitHub now. Unless they port iOS's playgrounds app to macOS, I'm not sure what would motivate apple to change that in the future.

- Dave

···

On Jun 22, 2017, at 02:55, tuuranton--- via swift-users <swift-users@swift.org> wrote:

> It is not. The first problem is that there is no
> value of "/path/to/swift" that will work everywhere.

Makes sense, but I guess one day macOS will ship with swift in a standard location like /usr/bin/swift so that would no longer be a problem.

Maybe just like python script

#!/usr/bin/env swift

···

tuuranton--- via swift-users <swift-users@swift.org> 於 2017年6月22日 下午5:55 寫道:

> It is not. The first problem is that there is no
> value of "/path/to/swift" that will work everywhere.

Makes sense, but I guess one day macOS will ship with swift in a standard location like /usr/bin/swift so that would no longer be a problem.

Out of curiosity, what are the some of the other problems?

_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users