Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User experience of developing a Tokamak project in Xcode #216

Closed
RayZhao1998 opened this issue Jul 27, 2020 · 6 comments
Closed

User experience of developing a Tokamak project in Xcode #216

RayZhao1998 opened this issue Jul 27, 2020 · 6 comments
Labels
documentation Technical writing, references, tutorials etc

Comments

@RayZhao1998
Copy link

  1. Is there any way to run the project and tests in Xcode instead of carton command line?

  2. The code completion seems to be broken. I've no idea whether it's my Xcode's problem.

Screen Shot 2020-07-28 at 12 38 53 AM

@MaxDesiatov MaxDesiatov added the documentation Technical writing, references, tutorials etc label Jul 27, 2020
@MaxDesiatov
Copy link
Collaborator

MaxDesiatov commented Jul 27, 2020

I'm afraid Xcode is not the best option here. It only knows how to build and run projects for Apple platforms and provides no customization for us to enable that. I personally use VSCode with a tasks.json file similar to this one. Then you can start carton dev in the integrated VSCode console in the dropdown invoked via Cmd-R, and if you stumble upon an error, you can command-click on the file with the line that carton prints in the console, which will locate the corresponding line in an editor tab for you.

For code completion to work Xcode needs to build the project, but it doesn't know how. As for VSCode, it could work with SourceKit-LSP in theory, but we need to patch it so that it could take the same command-line arguments that carton dev passes to swift build, specifically --triple and/or --destination. The way SourceKit-LSP is designed (and Xcode seems to follow that approach too), it needs to build the project to get the auto-completion index, and again it doesn't know how, but at least this part is open-source and we can fix it.

I realize that this is frustrating, so I want this to be fixed sooner rather than later. SourceKit-LSP depends on libIndexStore.dylib, and we need that one too to enable swift test --enable-test-discovery which would allows us to write proper test suites for Tokamak (and other projects obviously). This is being tracked in swiftwasm/swift#1495. I've attempted to build it in swiftwasm/swift#1456, but that currently fails. As soon as that is resolved I'll try building SourceKit-LSP with some patches to enable auto-completion in VSCode for all SwiftWasm projects.

@MaxDesiatov
Copy link
Collaborator

I'll keep the issue open until we have SourceKit-LSP working for VSCode and until all relevant documentation is updated accordingly.

@carson-katri
Copy link
Member

For now, if you import the shim Xcode will use the SwiftUI code completions.

@MaxDesiatov
Copy link
Collaborator

Yes, the shim is the TokamakShim module that you can import as shown in our README.md example code.

@MaxDesiatov
Copy link
Collaborator

MaxDesiatov commented Nov 12, 2020

With the latest version of Tokamak (0.5.1 right now) you can get syntax highlighting and autocomplete in Xcode by simply opening Package.swift of your project. Just make sure you use import TokamakDOM instead of import TokamakShim if you're on macOS Catalina.

You still need to use carton to build and run, but realistically I don't expect we'll be able to build for WebAssembly or debug browser apps directly from Xcode any time soon. At least as long as it's closed-source, or until it provides any extension points that help us implement that.

Based on that, I'm considering this issue resolved to the degree that's possible. Feel free to reopen if I missed anything.

@MaxDesiatov MaxDesiatov unpinned this issue Nov 12, 2020
@DanKorkelia
Copy link

That's amazing news! Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Technical writing, references, tutorials etc
Development

No branches or pull requests

4 participants