RLovelett / vscode-swift

An extension for VS Code which provides support for the Swift language.
https://marketplace.visualstudio.com/items?itemName=rlovelett.vscode-swift-language
MIT License
128 stars 7 forks source link

readme tweaks - #32

Closed johndpope closed 7 years ago

johndpope commented 7 years ago

your explanation here was great for debugging with xcode - https://github.com/RLovelett/vscode-swift/issues/27

consider bumping it to readme. it would help others help you.

johndpope commented 7 years ago

may help to also include this link https://code.visualstudio.com/docs/extensions/example-hello-world

johndpope commented 7 years ago

fyi - I had to create out / test / src directories.

And ran into a crash here

screen shot 2017-05-09 at 4 44 13 pm

was going to submit a PR - here's the gist.

   if let pg = try? ws.loadPackageGraph(){
            modules = Set(example(buildPath, .debug, pg, flags: buildFlags, toolchain: toolchain)
                .map({ SwiftModule(module: $0.0, commands: $0.1) }))
        }else{
            if #available(macOS 10.12, *) {
                  os_log("%{couldn't load package graph}@", log: log, type: .default)
            }

        }
RLovelett commented 7 years ago

Is the project that is causing this crash a SwiftPM project?

johndpope commented 7 years ago

Right. Not it wasn't. Maybe can help user by throwing an error instead of crashing. At this stage simply trying to get some hello world code going.

RLovelett commented 7 years ago

Ok yeah I think I can improve that. It should be able to handle a "bare" Swift folder too. It just isn't done efficiently yet (obviously).

johndpope commented 7 years ago

You may want to checkout johnsundell's marathon swift project / designed to run swift code simply. On iPhone otherwise would paste link.

johndpope commented 7 years ago

Hi @RLovelett - here's a bunch of links that maybe useful. https://github.com/JohnSundell/TestDrive https://github.com/johnsundell/marathon https://github.com/JohnSundell/ShellOut

Presumably - your only process is the LanguageServer that's simply dishing up rpc json. I'm a bit in the dark how the swift code is compiled. Is there a build swift line that gets run somewhere when user inside vs code presses debug?

RLovelett commented 7 years ago

The Swift code is analyzed by SourceKit. The actual code in the language server that interacts with SourceKit can be found in the module SourceKitter in the language server implementation.

I'm not 100% sure what I am supposed to be getting out of those links? Can you provide some more context?

johndpope commented 7 years ago

If I fire up vscode / and punch in some swift code / I want it to run the swift code when I press build / perhaps spitting out results to terminal window.

the marathon provides a way to avoid including the dependencies & constructing packages.

for example - say you want to create some bashScript.swift and include this framework (or any other SPM framework from github)

screen shot 2017-05-11 at 1 42 55 pm

there's no other files /cocoapods / carthage / SPM dependency checking.

code just runs. I don't want to change the way current setup runs / but perhaps consider option to augment it. How does the code build + run? or does it not?

RLovelett commented 7 years ago

If I fire up vscode / and punch in some swift code / I want it to run the swift code when I press build / perhaps spitting out results to terminal window.

This should already be possible with no plugins. Use a Task in Visual Studio Code. For example, this project uses a task to compile the TypeScript to JavaScript.

The extension and language server are designed to interrogate the source code not execute the source code (or at least not yet).

At this point adding this capability would represent a scope creep that I'm not willing to accept yet. It is still trying just to do the parts that are around code intelligence.

Of course pull requests are welcome! 😀

johndpope commented 7 years ago

Ok getting somewhere

Consider the task we want to run (when not a swift package ) is simply marathon And pass it the source file URL Then 🚀

I'll do some digging and keep an eye for fixes where we don't need a package.

On Thursday, May 11, 2017, Ryan Lovelett notifications@github.com wrote:

If I fire up vscode / and punch in some swift code / I want it to run the swift code when I press build / perhaps spitting out results to terminal window.

This should already be possible with no plugins. Use a Task in Visual Studio Code https://code.visualstudio.com/docs/editor/tasks. For example, this project uses a task to compile the TypeScript to JavaScript https://github.com/RLovelett/vscode-swift/blob/4f5a36e961177b93609569b486fb663beebfe029/.vscode/tasks.json .

The extension and language server are designed to interrogate the source code not execute the source code (or at least not yet).

At this point adding this capability would represent a scope creep that I'm not willing to accept yet. It is still trying just to do the parts that are around code intelligence.

Of course pull requests are welcome! 😀

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/RLovelett/vscode-swift/issues/32#issuecomment-300884553, or mute the thread https://github.com/notifications/unsubscribe-auth/AARsyj4N1RAg6DcE0x--D9Jzm8An9BuVks5r41nTgaJpZM4NVu9J .

--

John Pope | Senior Software Engineer BG Mobile Apps Pty Ltd

Port Melbourne, Australia T +61423562387 | E jp@bellgeorge.com tom@bellgeorge.com IN http://www.linkedin.com/in/jdpope

johndpope commented 7 years ago

{ "command": "marathon", "args": ["run ${file}"] }

Should actually do it. To resolve dependencies that swift file needs / wants

You just jump to terminal and say Marathon add GitHub.com/alamofire.git

We can point users in documentation or Have a bash script that auto installs language server and marathon.

JP

On Thursday, May 11, 2017, John Pope jp@bellgeorge.com wrote:

Ok getting somewhere

Consider the task we want to run (when not a swift package ) is simply marathon And pass it the source file URL Then 🚀

I'll do some digging and keep an eye for fixes where we don't need a package.

On Thursday, May 11, 2017, Ryan Lovelett <notifications@github.com javascript:_e(%7B%7D,'cvml','notifications@github.com');> wrote:

If I fire up vscode / and punch in some swift code / I want it to run the swift code when I press build / perhaps spitting out results to terminal window.

This should already be possible with no plugins. Use a Task in Visual Studio Code https://code.visualstudio.com/docs/editor/tasks. For example, this project uses a task to compile the TypeScript to JavaScript https://github.com/RLovelett/vscode-swift/blob/4f5a36e961177b93609569b486fb663beebfe029/.vscode/tasks.json .

The extension and language server are designed to interrogate the source code not execute the source code (or at least not yet).

At this point adding this capability would represent a scope creep that I'm not willing to accept yet. It is still trying just to do the parts that are around code intelligence.

Of course pull requests are welcome! 😀

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/RLovelett/vscode-swift/issues/32#issuecomment-300884553, or mute the thread https://github.com/notifications/unsubscribe-auth/AARsyj4N1RAg6DcE0x--D9Jzm8An9BuVks5r41nTgaJpZM4NVu9J .

--

John Pope | Senior Software Engineer BG Mobile Apps Pty Ltd

Port Melbourne, Australia T +61423562387 | E jp@bellgeorge.com javascript:_e(%7B%7D,'cvml','tom@bellgeorge.com'); IN http://www.linkedin.com/in/jdpope

--

John Pope | Senior Software Engineer BG Mobile Apps Pty Ltd

Port Melbourne, Australia T +61423562387 | E jp@bellgeorge.com tom@bellgeorge.com IN http://www.linkedin.com/in/jdpope

RLovelett commented 7 years ago

So I'm no longer sure what this issue is about. At first it seemed about updating the README, which I've done, then a application crash, and now something about marathon (which is still not clear what you want to use it for).

I'm going to close this because it is getting too messy for me to follow. If you want to file a new issue try and keep each separate so that I can follow them.

Thank you for the feedback.

johndpope commented 7 years ago

No worries. Here's the script to run swift file

https://gist.github.com/johndpope/28d56c1051e0c1836a3c284906a2278e

I'll dig up the crash in language server project.