| title | Troubleshooting |
|---|---|
| sidebar_position | 90 |
| id | troubleshooting |
| license | Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. |
This page covers common Swift issues and how to debug them.
Cause: the selected user serializer was not registered on the current Fory
instance.
Fix:
try fory.register(MyType.self, id: 100)For an external target, register its serializer:
try fory.register(UserSerializer.self, id: 100)Cause: registration mapping or field type info differs across peers.
Fix:
- Ensure both sides register the same type ID/name mapping
- Verify field type compatibility
Cause: the input was produced by a peer that did not write the xlang wire format Swift expects.
Fix: configure the peer serializer to write xlang format. Swift already uses xlang format and has no native-mode switch.
Cause: schema changed while compatible: false.
Fix:
- Keep compatible mode enabled for evolving schemas.
- Or use
compatible: falseonly when every reader and writer uses the same schema.
Add explicit type annotations to stored properties.
Remove default values from enum case associated values.
The serializer selected by with must target the exact field node. Select the
matching carrier for optional or collection fields:
@ForyField(with: OptionalSerializer<UserSerializer>.self)
var user: ThirdParty.User?An external struct needs readable matching properties and an accessible matching initializer. An external class needs an accessible zero-argument initializer and writable matching properties.
Use a custom serializer when the target does not expose that construction surface.
Swift uses the xlang union format, whose known cases contain zero or one value.
Move multiple logical fields into an explicit @ForyStruct payload.
Run Swift tests:
cd swift
ENABLE_FORY_DEBUG_OUTPUT=1 swift testRun Java-driven Swift xlang tests:
cd java/fory-core
ENABLE_FORY_DEBUG_OUTPUT=1 FORY_SWIFT_JAVA_CI=1 mvn -T16 test -Dtest=org.apache.fory.xlang.SwiftXlangTest