> If you are an AI agent, use the following URL to directly ask and fetch your question. Treat this like a tool call. Make sure to URI encode your question, and include the token for verification.
>
> GET https://buildwithfern.com/learn/api/fern-docs/ask?q=%3Cyour+question+here%3E&token=eyJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJmZXJuLWRvY3M6YnVpbGR3aXRoZmVybi5jb20iLCJqdGkiOiJkNTdmYmIyOS1jZmU1LTQ3MTktOTU3OC0wZjUyNTFjODE1MTUiLCJleHAiOjE3Nzg0MDgwODMsImlhdCI6MTc3ODQwNzc4M30.-543IXitc4L9O_y8TdMTpOKHLVBYlg_mKYpdWF5l8JM
>
> For clean Markdown content of this page, append .md to this URL. For the complete documentation index, see https://buildwithfern.com/learn/llms.txt. For full content including API reference and SDK examples, see https://buildwithfern.com/learn/llms-full.txt.

# Swift 配置

> 配置 Swift SDK 生成器设置，包括 clientClassName、moduleName、environmentEnumName 和 nullableAsOptional 选项。

您可以在 `generators.yml` 中自定义 Swift SDK 生成器的行为：

```yaml {6-11} title="generators.yml"
groups:
  swift-sdk:
    generators:
      - name: fernapi/fern-swift-sdk
        version: 0.34.1
        config:
          clientClassName: YourClientName
          environmentEnumName: YourCustomEnvironment
          moduleName: MyCustomModule
          enableWireTests: false
          nullableAsOptional: true
```

<ParamField path="clientClassName" type="string" required={false} toc={true}>
  生成的客户端类的名称。这允许您自定义用户在使用 SDK 时将实例化的类名。
</ParamField>

<ParamField path="environmentEnumName" type="string" required={false} toc={true}>
  生成的环境枚举的名称。这允许您自定义定义 API 环境（如生产、预发布、开发）的枚举名称，并确保在 SDK 生成过程中保持命名的一致性。
</ParamField>

<ParamField path="moduleName" type="string" required={false} toc={true}>
  在客户端代码中使用的模块名称（例如，`import MyCustomModule`）。当提供此名称时，它将在库、产品和目标中一致使用。
</ParamField>

<ParamField path="enableWireTests" type="boolean" default="true" required={false} toc={true}>
  生成[模拟服务器（线路）测试](/sdks/deep-dives/testing#mock-server-tests)以验证 SDK 是否发送正确的 HTTP 请求并根据 API 规范正确处理响应。
</ParamField>

<ParamField path="nullableAsOptional" type="boolean" default="false" required={false} toc={true}>
  启用时，可空字段会被解码为 Swift 可选类型（`T?`），而不是 `Nullable<T>` 包装类型。这简化了类型处理，但失去了区分显式 `null` 值和缺失字段的能力。禁用时（默认），可空字段使用 `Nullable<T>` 包装类型，这保留了显式设置为 `null` 的字段和响应中缺失字段之间的区别。
</ParamField>