title: Configuration sidebar_position: 2 id: configuration 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
This page covers ForyConfig and recommended runtime presets.
Fory is configured with:
public struct ForyConfig { public var xlang: Bool public var trackRef: Bool public var compatible: Bool }
Default configuration:
let fory = Fory() // xlang=true, trackRef=false, compatible=false
Fory is single-threaded and optimized to reuse one read/write context pair on the calling thread. Reuse one instance per thread and do not use the same instance concurrently.
xlangControls cross-language protocol mode.
true: Use xlang wire format (default)false: Use Swift-native modelet fory = Fory(xlang: true)
trackRefEnables shared/circular reference tracking for reference-trackable types.
false: No reference table (smaller/faster for acyclic or value-only graphs)true: Preserve object identity for class/reference graphslet fory = Fory(xlang: true, trackRef: true)
compatibleEnables compatible schema mode for evolution across versions.
false: Schema-consistent mode (stricter, lower metadata overhead)true: Compatible mode (supports add/remove/reorder fields)let fory = Fory(xlang: true, trackRef: false, compatible: true)
let fory = Fory(xlang: false, trackRef: false, compatible: false)
let fory = Fory(xlang: true, trackRef: false, compatible: true)
let fory = Fory(xlang: true, trackRef: true, compatible: true)