DUE TO SPAM, SIGN-UP IS DISABLED. Goto Selfserve wiki signup and request an account.
...
Contents
...
Apache Fory Implement Fory Dart gRPC integration
Description
Apache Fory does not yet generate Dart gRPC service bindings.
This project will add Dart gRPC code generation to the Fory compiler. For each service definition, the compiler should generate Dart service interfaces and gRPC transport bindings that follow the existing Dart generator layout and use a Fory codec instead of protobuf runtime payload types.
The implementation must keep the Fory runtime free of gRPC dependencies. Any required gRPC glue should be emitted as generated helper code. Runtime behavior should remain low-overhead and allocation-conscious.
Potential Outcomes
- Generate Dart service interface and gRPC binding outputs from service definitions, aligned with current Dart generator conventions.
- Generate Dart gRPC server and client stubs for unary and streaming RPCs using Dart gRPC APIs.
- Wire request/response handling through generated Fory serializer and deserializer functions.
- Implement zero-copy deserialization buffer support for inbound gRPC payloads, with a safe fallback path when zero-copy cannot be applied.
- Coordinate with Dart type generation so emitted message, enum, and union types are directly usable by generated gRPC stubs.
- Add golden codegen tests for generated file names and key signatures.
- Provide a runnable Dart server/client example using generated bindings and the Fory codec.
- Update compiler documentation for Dart gRPC code generation usage and constraints.
Skills:Dart, gRPC (`grpc`), compiler/code generation, serialization internals, async programming, testing, performance optimization.
Difficulty: Medium
Project size:175 hours
Potential mentors:Chaokun Yang, Weipeng Wang
Source links:
- https://github.com/apache/fory/issues/3279
- https://github.com/apache/fory/issues/3281
- https://fory.apache.org/docs/next/compiler/compiler_guide
- https://github.com/apache/fory/tree/main/compiler
- https://github.com/apache/fory/tree/main/dart
- https://github.com/apache/fory/blob/main/dart/README.md
- https://github.com/apache/fory/tree/main/dart/packages/fory
Apache Fory - Schema IDL Codegen and gRPC Integration for Apache Fory Swift
Apache Fory has a mature compiler pipeline for FDL, Protocol Buffers, and FlatBuffers frontends, plus code generators for Java, Python, Go, Rust, and C++. The compiler also already includes service IR parsing and a `--grpc` generation path, but Swift code generation is not yet supported.
This project adds end-to-end Swift support in two layers:
1. Swift schema and model code generation from Fory IR.
2. Swift gRPC generation from service definitions, including transport bindings and a Fory-backed codec.
The implementation should follow existing compiler conventions and prioritize low-overhead, allocation-conscious runtime behavior.
Problem Statement
The repository already contains a Swift runtime (`swift/Sources/Fory`) but lacks compiler-generated Swift model code and Swift gRPC bindings from IDL files. This creates a gap:
- Swift users cannot use `foryc` to generate model types from `.fdl`, `.proto`, or `.fbs`.
- Service definitions parsed into compiler IR cannot yet target Swift transport code.
- There is no official Fory codec integration for grpc-swift.
Why This Project Matters
- Completes the Swift developer workflow: IDL -> generated models -> generated service APIs -> runnable gRPC client and server.
- Reuses existing multi-frontend service parsing support in compiler IR.
- Aligns Swift with other language targets and improves cross-language consistency.
- Enables high-performance Swift service communication using Fory serialization semantics.
Expected Outcomes
- Add Swift as a first-class compiler target (`
{}lang swift`, `{-}-swift_out`). - Generate Swift model code from schema definitions (messages, enums, unions, nested types).
- Generate `service_grpc.swift` from service definitions.
- Generate grpc-swift compatible async server and client wrappers.
- Implement a custom grpc-swift codec backed by Fory serialization and deserialization.
- Implement inbound zero-copy decode support with a safe copy fallback path.
- Add golden-style codegen tests for filenames and key generated signatures.
- Add cross-frontend parity tests for FDL, proto, and fbs service definitions.
- Provide runnable Swift server and client example(s) using generated code and codec.
- Document compiler usage, constraints, and integration steps.
Detailed Scope
1) Compiler and CLI Integration
- Add `SwiftGenerator` under `compiler/fory_compiler/generators/`.
- Register generator in `compiler/fory_compiler/generators/{}init{}.py`.
- Extend CLI output mapping and options to support `--swift_out`.
- Ensure `--lang swift` works with existing recursive import compilation flow.
2) Swift Model Code Generation
Generate Swift for:
- Enums
- Messages
- Unions
- Nested types
- Type registration helper APIs
Requirements:
- Follow Fory type ID behavior (explicit IDs, auto IDs, namespace/name registration fallback).
- Match existing cross-language semantics where applicable.
- Integrate with existing Swift runtime abstractions (`Serializer`, type resolver, registration APIs).
3) Swift Service and gRPC Code Generation
For each schema service:
- Generate `service.swift` containing service protocol and method shape declarations.
- Generate `service_grpc.swift` containing grpc-swift server and client transport bindings.
Required RPC support:
- Unary
- Client streaming
- Server streaming
- Bidirectional streaming
4) Fory Codec for grpc-swift
- Implement codec encode and decode using Fory Swift runtime.
- Ensure request and response types map correctly to generated Swift types.
- Provide clear error mapping for decode and type mismatch failures.
5) Zero-Copy Decode and Fallback
- Add a zero-copy-friendly decode path for inbound payload handling when safe ownership and lifecycle constraints are satisfied.
- Add a fallback path that copies payload bytes when zero-copy cannot be safely applied.
- Ensure behavior is deterministic and memory-safe.
6) Tests
Compiler tests:
- Add codegen tests validating generated Swift file names and key signatures.
- Add service generation tests for all RPC modes.
- Add cross-frontend equivalence tests for FDL/proto/fbs service definitions.
Swift runtime and integration tests:
- Codec round-trip tests.
- Error-path tests (invalid payload, type mismatch, unsupported mode).
- Zero-copy path and fallback path coverage.
7) Examples and Documentation
- Add runnable Swift gRPC server/client example using generated files.
- Update `docs/compiler/compiler-guide.md` for Swift codegen options and usage.
- Update `docs/compiler/generated-code.md` with Swift output layout and generated API shape.
- Add concise Swift integration documentation for grpc-swift + Fory codec.
Performance and Quality Requirements
- Keep allocation count low on encode and decode paths.
- Avoid unnecessary data copies in transport integration.
- Keep generated code predictable and stable for golden-style testing.
- Preserve compiler behavior for existing languages and frontends.
Milestones (Recommended)
1. Community Bonding
- Finalize generated API naming and file layout.
- Confirm Swift option strategy and dependency constraints.
- Agree on test matrix and acceptance checklist.
2. Phase 1
- Implement Swift generator base and CLI wiring.
- Generate core model types and registration helpers.
- Add baseline model codegen tests.
3. Phase 2
- Implement service generation (`service.swift`, `service_grpc.swift`).
- Support unary and all streaming RPC method shapes.
- Add service signature and transport generation tests.
4. Phase 3
- Implement and validate Fory grpc-swift codec.
- Implement zero-copy decode path and fallback path.
- Add integration example and end-to-end tests.
Finalization
- Documentation updates.
- Stability pass and cleanup.
- Final validation across compiler and Swift test suites.
Acceptance Criteria
1. `foryc` supports Swift generation through `{}lang swift` and `{-}-swift_out`.
2. Swift model code compiles and integrates with Fory Swift runtime.
3. Service generation outputs `service.swift` and `service_grpc.swift` with correct signatures.
4. Unary, client-streaming, server-streaming, and bidi-streaming methods are correctly generated.
5. Fory-backed grpc-swift codec works for request and response round-trip.
6. Zero-copy decode path exists with tested fallback behavior.
7. Added tests pass and no regressions are introduced in existing compiler suites.
8. Documentation and runnable Swift example are complete and usable.
Skills Required
- Swift
- grpc-swift
- Compiler and code generation
- Serialization internals
- Async and streaming APIs
- Testing and performance profiling
Difficulty
Hard
Project Size
350 hours
Potential Mentors
- Chaokun Yang
- Weipeng Wang
Source Links
- https://github.com/apache/fory/issues/3370
- https://fory.apache.org/docs/next/compiler/compiler_guide
- https://github.com/apache/fory/tree/main/compiler
- https://github.com/apache/fory/tree/main/compiler/fory_compiler
- https://github.com/apache/fory/tree/main/compiler/fory_compiler/tests
- https://github.com/apache/fory/tree/main/swift
- https://fory.apache.org/docs/guide/rust/
- https://github.com/grpc/grpc-swift
...