Skip to content

Add Swift Package interface wrapping the C library#61

Open
willwade wants to merge 4 commits intomainfrom
add-swift-interface-14334735343406533808
Open

Add Swift Package interface wrapping the C library#61
willwade wants to merge 4 commits intomainfrom
add-swift-interface-14334735343406533808

Conversation

@willwade
Copy link
Copy Markdown
Collaborator

@willwade willwade commented May 5, 2026

This commit adds a native Swift interface that wraps the existing C library, allowing the project to be consumed as a Swift Package via Swift Package Manager (SPM).

The wrapper provides an idiomatic Swift API parity with the Python and Node interfaces. Due to SPM's path constraints, Package.swift was placed at the repository root. Tests have been written for all key functional areas and integrated into the GitHub Actions CI workflow.


PR created automatically by Jules for task 14334735343406533808 started by @willwade

- Added `Package.swift` at the root to configure the Swift package
- Created `WorldAlphabetsC` target referencing the C source code
- Created `WorldAlphabets` Swift target wrapping the C functionality
- Added native Swift types mapping to C structures
- Implemented Swift tests to verify the wrapper
- Updated GitHub Actions to run Swift tests on push

Co-authored-by: willwade <229352+willwade@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

- Corrected the C-interop logic when passing an array of `UnsafePointer<CChar>?` to a C function expecting a double pointer.
- Used `withUnsafeMutableBufferPointer` to safely obtain the base address of the Swift array to satisfy the compiler requirements.

Co-authored-by: willwade <229352+willwade@users.noreply.github.com>
@willwade
Copy link
Copy Markdown
Collaborator Author

willwade commented May 5, 2026

Docs / read me needs updating

@google-labs-jules
Copy link
Copy Markdown
Contributor

Docs / read me needs updating

I have updated the README.md to mention the Swift interface, included an SPM badge, and added a Swift usage section with code examples.

- Added Swift Package Manager badge to README.
- Updated main description to include the Swift interface.
- Added a Swift Usage section containing installation instructions and basic code examples.

Co-authored-by: willwade <229352+willwade@users.noreply.github.com>
@willwade
Copy link
Copy Markdown
Collaborator Author

willwade commented May 5, 2026

im still seeing errors in the "Lint and Test / Test Swift (push)"

@google-labs-jules
Copy link
Copy Markdown
Contributor

im still seeing errors in the "Lint and Test / Test Swift (push)"

I see the test error related to worldalphabets_data.h not being found. SPM does not support nested cSettings or non-standard directory structures perfectly. I will add a cSettings directive in Package.swift to ensure the generated directory is included in the header search path.

- Added `cSettings` with `.headerSearchPath` directives for both `generated` and `include` directories.
- This resolves build failures where the C compiler in Swift Package Manager cannot locate the generated headers (like `worldalphabets_data.h`) when compiling the C source files.

Co-authored-by: willwade <229352+willwade@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant