- 
                Notifications
    You must be signed in to change notification settings 
- Fork 252
[WIP] Summer of code 2025 summary posts #1191
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
          
     Draft
      
      
            ktoso
  wants to merge
  6
  commits into
  swiftlang:main
  
    
      
        
          
  
    
      Choose a base branch
      
     
    
      
        
      
      
        
          
          
        
        
          
            
              
              
              
  
           
        
        
          
            
              
              
           
        
       
     
  
        
          
            
          
            
          
        
       
    
      
from
ktoso:gsoc-posts-2025
  
      
      
   
  
    
  
  
  
 
  
      
    base: main
Could not load branches
            
              
  
    Branch not found: {{ refName }}
  
            
                
      Loading
              
            Could not load tags
            
            
              Nothing to show
            
              
  
            
                
      Loading
              
            Are you sure you want to change the base?
            Some commits from the old base branch may be removed from the timeline,
            and old review comments may become outdated.
          
          
  
     Draft
                    Changes from 5 commits
      Commits
    
    
            Show all changes
          
          
            6 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      cd5789e
              
                Prepare summer of code summary posts
              
              
                ktoso 7d30548
              
                Apply suggestions from code review
              
              
                ktoso 812557a
              
                cleanups
              
              
                ktoso f1013ce
              
                Cleanups, add link to serverside swift talk
              
              
                ktoso 706b23c
              
                Update _posts/2025-11-NN-swift-gsoc-2025-highlight-3-vscode-swift-lsp…
              
              
                ktoso 183940c
              
                Update _data/authors.yml
              
              
                ktoso File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
|  | @@ -551,3 +551,27 @@ mitchellallison: | |
| email: [email protected] | ||
| github: mitchellallison | ||
| about: "Mitchell Allison works on Distributed Systems in Swift at Apple." | ||
|  | ||
| mads: | ||
| name: Mads Odgaard | ||
| email: [email protected] | ||
| github: madsodgaard | ||
| about: Mads is a Google Summer of Code 2025 contributor, where he worked on bringing JNI support to the jextract tool which is part of the Swift Java interoperability project. | ||
|  | ||
| ahmedelrefaey: | ||
| name: Ahmed Elrefaey | ||
| email: [email protected] | ||
| github: a7medev | ||
| about: Ahmed is a Google Summer of Code 2025 contributor, where he worked on improving the display of Swift documentation during code completion in SourceKit-LSP and VS Code. | ||
|  | ||
| kelvin: | ||
| name: Tien Quoc (Kelvin) Bui | ||
| email: [email protected] | ||
| github: tienquocbui | ||
| about: Kelvin is a Google Summer of Code 2025 code contributor, where he worked on improving the console output for Swift Testing. | ||
|  | ||
| priyambada: | ||
| name: Priyambada Roul | ||
| email: [email protected] | ||
| github: roulpriya | ||
| about: Priyambada is a Google Summer of Code 2025 code contributor, where she worked on providing Swiftly support in VSCode. | ||
        
          
  
    
      
          
            99 changes: 99 additions & 0 deletions
          
          99 
        
  _posts/2025-11-NN-swift-gsoc-2025-highlight-1-vscode-swiftly.md
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| --- | ||
| layout: new-layouts/post | ||
| published: true | ||
| date: 2025-02-NN 10:00:00 | ||
| title: 'Swift GSoC 2025 highlight: Swiftly (Swift installer) support in Visual Studio Code | ||
| author: [ktoso, priyambada] | ||
| category: "Community" | ||
| --- | ||
|  | ||
| Another year of successful Swift participation in [Google Summer of Code](https://summerofcode.withgoogle.com) 2025 came to an end recently, and this year we'd like to shine some light on the projects and work acomplished during the summer! | ||
|  | ||
| Summer of Code is an annual program, organized by Google, which provides hands-on experience for newcomers contributing | ||
| to open source projects. Participants usually are students, but do not have to be. | ||
|  | ||
| In this series of four posts, we'll highlight each of the Summer of Code contributors and their projects. | ||
| You can navigate between the posts using these convenient links: | ||
|  | ||
| - Bringing Swiftly support to VS Code (this post) | ||
| - [JNI mode for swift-java’s source jextract tool](2025-11-NN-swift-gsoc-2025-highlight-2-swift-java-jextract-jni-mode.md) | ||
| - [Improve the display of documentation during code completion in SourceKit-LSP](2025-11-NN-swift-gsoc-2025-highlight-3-vscode-swift-lsp-documentation.md) | ||
| - [Improved Console Output for Swift Testing](2025-11-NN-swift-gsoc-2025-highlight-4-swift-testing-output.md) | ||
|  | ||
| What follows, is a shortened writeup about their project and experience by the GSoC contributors. | ||
| If you'd like to learn more, please check out the full version of their posts on the Swift forums (linked below)! | ||
|  | ||
| --- | ||
|  | ||
| ## Bringing Swiftly support to VS Code | ||
|  | ||
| Hi Swift community! 👋 | ||
|  | ||
| I am Priyambada Roul. I'm incredibly excited to share what I've been working on over the past three months as part of Google Summer of Code 2025 with Swift.org, alongside my mentors, @cmcgee1024 @matthewbastien | ||
|  | ||
| My project focused on integrating **Swiftly** (Swift's toolchain manager) into the **VS Code Swift extension.** | ||
|  | ||
| ## The Problem We Solved | ||
|  | ||
| We've made switching toolchains easier with Swiftly, allowing you to install and switch between Swift versions without leaving VS Code. | ||
|  | ||
| 1. **Switch Swift versions** with a single click | ||
|  | ||
| 2. **Install new toolchains** without leaving VS Code | ||
|  | ||
| 3. **See real-time progress** during installations | ||
|  | ||
| 4. **Automatically sync** with project-specific Swift versions | ||
|  | ||
| ## What's New for Swift Developers | ||
|  | ||
| ### Swiftly VS Code Integration | ||
|  | ||
| The VS Code extension now provides an entirely **seamless toolchain management experience**: | ||
|  | ||
| * We now support macOS too! | ||
|  | ||
| * See your current Swift version in the VS Code status bar. | ||
|  | ||
| * Click the version to switch between installed toolchains instantly. | ||
|  | ||
| * Install any Swift version directly from VS Code with real-time progress. | ||
|  | ||
| * Automatic detection of .swift-version files with prompts to switch | ||
|  | ||
| ### Enhanced Swiftly CLI | ||
|  | ||
| * Swiftly now supports a machine-readable JSON output format. | ||
|  | ||
| * Swiftly now reports toolchain installation progress updates in **JSONL format** | ||
|  | ||
| * We have polished error reporting. | ||
|  | ||
|  | ||
|  | ||
|  | ||
|  | ||
|  | ||
|  | ||
| ### Things I learnt | ||
|  | ||
| * Making a VS Code extension. While I have experience with TypeScript from web development, the VS Code extension API and its development workflow are different from what I'm used to. | ||
|  | ||
| * I understood the structure and distribution of Swift toolchains, as well as how different versions can coexist on the same system using symlinks, environment variables, and PATH manipulation, across both macOS and Linux. | ||
|  | ||
| * The extension spawns Swiftly processes and reads their JSON output streams in real-time. This involved learning about IPC mechanisms, stdin/stdout buffering and process lifecycle management. | ||
|  | ||
| Want to see what we built? Check out the repositories: | ||
|  | ||
| * **VS Code Swift Extension**: [github.com/swiftlang/vscode-swift](https://github.com/swiftlang/vscode-swift) | ||
|  | ||
| * **Swiftly CLI**: [github.com/swiftlang/swiftly](https://github.com/swiftlang/swiftly) | ||
|  | ||
| I have linked all pull requests and technical details in my **[detailed project report](https://docs.google.com/document/d/1Mnb9ybmVkpL6pAgrpMbSg6EV3owA2rz_FgltvAXdnUE/edit?tab=t.0)**, which provides an in-depth look into the specific changes. | ||
|  | ||
| This GSoC experience has been transformative. I came in as someone intimidated by large codebases, and I'm leaving with the confidence to tackle complex, multi-tool integrations. I'm excited to continue contributing to Swift community! | ||
|  | ||
|  | ||
| --- | ||
|  | ||
| If you'd like to learn more about this project, please [check out the full post on the Swift forums](https://forums.swift.org/t/gsoc-2025-bringing-swiftly-support-to-vs-code/81886)! | 
        
          
  
    
      
          
            130 changes: 130 additions & 0 deletions
          
          130 
        
  _posts/2025-11-NN-swift-gsoc-2025-highlight-2-swift-java-jextract-jni-mode.md
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,130 @@ | ||
| --- | ||
| layout: new-layouts/post | ||
| published: true | ||
| date: 2025-02-NN 10:00:00 | ||
| title: 'Swift GSoC 2025 highlight: JNI mode for SwiftJava interoperability jextract tool | ||
| author: [ktoso, mads] | ||
| category: "Community" | ||
| --- | ||
|  | ||
| Another year of successful Swift participation in [Google Summer of Code](https://summerofcode.withgoogle.com) 2025 came to an end recently, and this year we'd like to shine some light on the projects and work acomplished during the summer! | ||
|  | ||
| Summer of Code is an annual program, organized by Google, which provides hands-on experience for newcomers contributing | ||
| to open source projects. Participants usually are students, but do not have to be. | ||
|  | ||
| In this series of four posts, we'll highlight each of the Summer of Code contributors and their projects. | ||
|  | ||
| - [Bringing Swiftly support to VS Code](2025-11-NN-swift-gsoc-2025-highlight-1-vscode-swiftly.md) | ||
| - JNI mode for swift-java’s source jextract tool (this post) | ||
| - [Improve the display of documentation during code completion in SourceKit-LSP](2025-11-NN-swift-gsoc-2025-highlight-3-vscode-swift-lsp-documentation.md) | ||
| - [Improved Console Output for Swift Testing](2025-11-NN-swift-gsoc-2025-highlight-4-swift-testing-output.md) | ||
|  | ||
| --- | ||
|  | ||
| ## JNI mode for SwiftJava interoperability jextract tool | ||
|  | ||
| My name is Mads and I am excited to share with you what I have been working on for Swift/Java interoperability over the summer with my mentor Konrad for Google Summer of Code 2025. | ||
|  | ||
| # Overview | ||
|  | ||
| > You can also view Mads' presentation from the Serverside.swift conference about his work on this project: [Expanding Swift/Java Interoperability](https://www.youtube.com/watch?v=tOH6V1IvTAc). | ||
|  | ||
| The [swift-java](https://github.com/swiftlang/swift-java) interoperability library provides the `swift-java jextract` tool, which automatically generates Java sources that are used to call Swift code from Java. Previously, this tool only worked using the [Foreign Function and Memory API (FFM)](https://docs.oracle.com/en/java/javase/21/core/foreign-function-and-memory-api.html), which requires JDK 22+, making it unavailable on platforms such as Android. The goal of this project was to extend the jextract tool, such that it is able to generate Java sources using JNI instead of FFM and thereby allowing more platforms to utilize Swift/Java interoperability. | ||
|  | ||
| I am very glad to report that we have succeeded in that goal, supporting even more features than initially planned! Our initial goal was to achieve feature parity with the FFM mode, but the new JNI mode also supports additional Swift language features such as enums and protocols! | ||
|  | ||
| With the outcome of this project, you can now run the following command to automatically generate Java wrappers for your Swift library using JNI, therefore opening up the possibility of using it on platforms such as Android. | ||
|  | ||
| ```bash | ||
| swift-java jextract --swift-module MySwiftLibrary \ | ||
| --mode jni \ | ||
| --input-swift Sources/MySwiftLibrary \ | ||
| --output-java out/java \ | ||
| --output-swift out/swift | ||
| ``` | ||
|  | ||
| # How does it work? | ||
|  | ||
| Each Swift class/struct is extracted as a single Java `class`. Functions and variables are generated as Java methods, that internally calls down to a native method that is implemented in Swift using `@_cdecl`. Take a look at the following example: | ||
|  | ||
| ```swift | ||
| public class MySwiftClass { | ||
| public let x: Int64 | ||
| public init(x: Int64) { | ||
| self.x = x | ||
| } | ||
|  | ||
| public func printMe() { | ||
| print(“\(self.x)”); | ||
| } | ||
| } | ||
| ``` | ||
|  | ||
| It is roughly generated to the equivalent Java `class`: | ||
|  | ||
| ```java | ||
| public final class MySwiftClass implements JNISwiftInstance { | ||
| public static MySwiftClass init(long x, long y, SwiftArena swiftArena$) { | ||
| return MySwiftClass.wrapMemoryAddressUnsafe(MySwiftClass.$init(x, y), swiftArena$); | ||
| } | ||
|  | ||
| public long getX() { | ||
| return MySwiftClass.$getX(this.$memoryAddress()); | ||
| } | ||
|  | ||
| public void printMe() { | ||
| MySwiftClass.$printMe(this.$memoryAddress()); | ||
| } | ||
|  | ||
| private static native long $init(long x, long y); | ||
| private static native long $getX(long self); | ||
| private static native void $printMe(long self); | ||
| } | ||
| ``` | ||
| We also generate additional Swift thunks that actually implement the `native` methods and call the underlying Swift methods. | ||
|  | ||
| You can learn more about how the memory allocation and management works [in the full version of this post of this post on the Swift forums](https://forums.swift.org/t/gsoc-2025-new-jni-mode-added-to-swift-java-jextract-tool/81858)! | ||
|  | ||
| An interesting aspect of an interoperability library such as `swift-java` is the memory management between the two sides, in this case the JVM and Swift. The FFM mode uses the FFM APIs around `MemorySegment` to allocate and manage native memory. We are not so lucky in JNI. In older Java versions there are different ways of allocating memory, such as `Unsafe` or `ByteBuffer.allocateDirect()`. We could have decided to use these and allocate memory on the Java side, like FFM, but instead we decided to move the responsibility to Swift, which allocates the memory instead. This had some nice upsides, as we did not have to mess the the witness tables like FFM does. | ||
|  | ||
| > For more info on memory in FFM, I strongly recommend watching Konrad’s talk [try\! Swift Tokyo 2025 \- Foreign Function and Memory APIs and Swift/Java interoperability](https://www.youtube.com/watch?v=vgtzhTOhEbs) | ||
|  | ||
| The most obvious place we need to allocate memory is when we initialize a wrapped Swift `class`. Take a look at the following generated code for a Swift initializer: | ||
| ```java | ||
| public static MySwiftClass init(SwiftArena swiftArena$) { | ||
| return MySwiftClass.wrapMemoryAddressUnsafe(MySwiftClass.$init(), swiftArena$); | ||
| } | ||
| private static native long $init(); | ||
| ``` | ||
| Here we see that we are calling a native method `$init` which returns a `long`. This value is a pointer to the Swift instance in the memory space of Swift. It is passed to `wrapMemoryAddressUnsafe`, which is basically just storing the pointer in a local field and registering the wrapper to the `SwiftArena`. | ||
|  | ||
| `SwiftArena` is a type that is used to ensure we eventually deallocate the memory when the Java wrapper is no longer needed. There exists two implements of this: | ||
|  | ||
| 1. `SwiftArena.ofConfined()`: returns a confined arena which is used with *try-with-resource*, to deallocate all instances at the end of some scope. | ||
| 2. `SwiftArena.ofAuto()`: returns an arena that deallocates instances once the garbage-collector has decided to do so. | ||
|  | ||
| This concept also exists in the FFM mode, and I recommend watching Konrad’s talk to learn more about them! | ||
|  | ||
| If we take a look at the native implementation of `$init` in Swift, we see how we allocate and initialize the memory: | ||
| ```swift | ||
| // Generated code, not something you would write | ||
|  | ||
| @_cdecl("Java_com_example_swift_MySwiftClass__00024init__JJ") | ||
|         
                  ktoso marked this conversation as resolved.
              Show resolved
            Hide resolved | ||
| func Java_com_example_swift_MySwiftClass__00024init__JJ(environment: UnsafeMutablePointer<JNIEnv?>!, thisClass: jclass, x: jlong, y: jlong) -> jlong { | ||
| let result$ = UnsafeMutablePointer<MySwiftClass>.allocate(capacity: 1) | ||
| result$.initialize(to: MySwiftClass.init(x: Int64(fromJNI: x, in: environment!), y: Int64(fromJNI: y, in: environment!))) | ||
| let resultBits$ = Int64(Int(bitPattern: result$)) | ||
| return resultBits$.getJNIValue(in: environment!) | ||
| } | ||
| ``` | ||
| We are basically allocating memory for a single instance of `MySwiftClass`, initializing it to a new instance and returning the memory address of the pointer. It is the same approach for `struct` as well\! | ||
|  | ||
| # My experience with GSoC | ||
|  | ||
| Google Summer of Code was an awesome experience for me\! I got to work with my favourite language on a library that is very relevant\! A **HUGE** thanks to my mentor @ktoso, who provided invaluable guidance, was always available for questions and allowed me to experiment and take ownership of the work\! | ||
|  | ||
| I would definitely recommend GSoC to anyone interested, it is a great way to engage with the open-source community, develop your skills and work with some talented people\! My number one advice would be to never be afraid of asking seemingly “stupid” questions, they might not be that stupid afterall. | ||
|  | ||
| --- | ||
|  | ||
| If you'd like to learn more about this project, please [check out the full post on the Swift forums](https://forums.swift.org/t/gsoc-2025-new-jni-mode-added-to-swift-java-jextract-tool/81858) as it contains lots of more additional examples and in-depth discussion about memory management and trade-offs this project had to resolve! | ||
        
          
  
    
      
          
            64 changes: 64 additions & 0 deletions
          
          64 
        
  _posts/2025-11-NN-swift-gsoc-2025-highlight-3-vscode-swift-lsp-documentation.md
  
  
      
      
   
        
      
      
    |         
                  ktoso marked this conversation as resolved.
              Show resolved
            Hide resolved | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| --- | ||
| layout: new-layouts/post | ||
| published: true | ||
| date: 2025-02-NN 10:00:00 | ||
| title: 'Swift GSoC 2025 highlight: Improve the display of documentation during code completion in SourceKit-LSP | ||
| author: [ktoso, ahmedelrefaey, hamish] | ||
| category: "Community" | ||
| --- | ||
|  | ||
| Another year of successful Swift participation in [Google Summer of Code](https://summerofcode.withgoogle.com) 2025 came to an end recently, and this year we'd like to shine some light on the projects and work acomplished during the summer! | ||
|  | ||
| Summer of Code is an annual program, organized by Google, which provides hands-on experience for newcomers contributing | ||
| to open source projects. Participants usually are students, but do not have to be. | ||
|  | ||
| In this series of four posts, we'll highlight each of the Summer of Code contributors and their projects. | ||
|  | ||
| - [Bringing Swiftly support to VS Code](2025-11-NN-swift-gsoc-2025-highlight-1-vscode-swiftly.md) | ||
| - [JNI mode for swift-java’s source jextract tool](2025-11-NN-swift-gsoc-2025-highlight-2-swift-java-jextract-jni-mode.md) | ||
| - Improve the display of documentation during code completion in SourceKit-LSP (this post) | ||
| - [Improved Console Output for Swift Testing](2025-11-NN-swift-gsoc-2025-highlight-4-swift-testing-output.md) | ||
|  | ||
| --- | ||
|  | ||
| ## Improve the display of documentation during code completion in SourceKit-LSP | ||
|  | ||
| Hi everyone! | ||
|  | ||
| This is Ahmed Elrefaey, I’m excited to share with you an update on my GSoC project, Improve the display of documentation during code completion in SourceKit-LSP, mentored by Hamish Knight. | ||
|  | ||
| ### Project Goals | ||
|  | ||
| The aim of this project is to enhance how documentation is displayed in SourceKit-LSP during code completion by: | ||
|  | ||
| 1. Showing the full documentation for a code completion item instead of the first paragraph only, which we call “brief documentation”. | ||
| 2. Implementing Language Server Protocol’s [signature help](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_signatureHelp) request showing the user which overloads are available, along with their corresponding documentation. | ||
|  | ||
| ### Progress | ||
|  | ||
| During this summer, we have made great progress on this project that I want to share with you. | ||
|  | ||
| We have successfully implemented full documentation comment retrieval for completion items by lazily retrieving the full documentation comment upon request to avoid having to fetch all documentation comments at once. | ||
|  | ||
| Here’s what SourceKit-LSP currently provides in VS Code (brief documentation): | ||
|  | ||
|  | ||
|  | ||
| And here’s how it looks with full documentation: | ||
|  | ||
|  | ||
|  | ||
| We have also implemented a large portion of signature help support, showing the available overloads and their corresponding documentation while editing. | ||
| We reused the existing argument completion logic to determine the overloads and refactored the code completion item description implementation to reuse it in signature help. | ||
|  | ||
| Here’s a quick demo of signature help in VS Code. | ||
|  | ||
|  | ||
|  | ||
| ### Closing Thoughts | ||
|  | ||
| I'm incredibly grateful for this opportunity to contribute to the Swift project, and I really learned a lot from this experience. I'd like to thank my mentor, Hamish Knight, for his unwavering support and guidance throughout this summer. I’d also like to thank Alex Hoppen, Rintaro Ishizaki, and Ben Barham for their valuable feedback during code review. | ||
|  | ||
| --- | ||
|  | ||
| If you'd like to learn more about this project, please [check out the full post on the Swift forums](https://forums.swift.org/t/gsoc-2025-improve-the-display-of-documentation-during-code-completion-in-sourcekit-lsp/81976)! | 
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.