This is an automated email from the ASF dual-hosted git repository. chaokunyang pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/fory-site.git
commit ae100befbb2df0ef7c9c074dc783b442786a77c3 Author: chaokunyang <[email protected]> AuthorDate: Sat Feb 28 08:01:06 2026 +0000 🔄 synced local 'docs/guide/' with remote 'docs/guide/' --- docs/guide/swift/cross-language.md | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/docs/guide/swift/cross-language.md b/docs/guide/swift/cross-language.md index f4b1781a4d..202748d901 100644 --- a/docs/guide/swift/cross-language.md +++ b/docs/guide/swift/cross-language.md @@ -54,6 +54,40 @@ try fory.register(Order.self, namespace: "com.example", name: "Order") - Use compatible mode when independently evolving schemas - Register all user-defined concrete types used by dynamic fields (`Any`, `any Serializer`) +## Swift IDL Workflow + +Generate Swift models directly from Fory IDL/Proto/FBS inputs: + +```bash +foryc schema.fdl --swift_out ./Sources/Generated +``` + +Generated Swift code includes: + +- `@ForyObject` models and `@ForyField(id: ...)` metadata +- Tagged union enums (associated-value enum cases) +- `ForyRegistration.register(_:)` helpers with transitive import registration +- `toBytes` / `fromBytes` helpers on generated types + +Use generated registration before cross-language serialization: + +```swift +let fory = Fory(xlang: true, trackRef: true, compatible: true) +try Addressbook.ForyRegistration.register(fory) + +let payload = try fory.serialize(book) +let decoded: Addressbook.AddressBook = try fory.deserialize(payload) +``` + +### Run Swift IDL Integration Tests + +```bash +cd integration_tests/idl_tests +./run_swift_tests.sh +``` + +This runs Swift roundtrip matrix tests and Java peer roundtrip checks (`IDL_PEER_LANG=swift`). + ## Debugging Cross-language Tests Enable debug output when running xlang tests: --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
