Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions fern/products/sdks/overview/swift/configuration.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
title: Swift configuration
description: Configuration options for the Fern Swift SDK.
---

You can customize the behavior of the Swift SDK generator in `generators.yml`:

```yaml {7-8} title="generators.yml"
default-group: local
groups:
local:
generators:
- name: fernapi/fern-swift-sdk
version: <Markdown src="/snippets/version-number-swift.mdx"/>
```

## SDK Configuration Options
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm I'm not seeing this page in the preview URL. Is that expected?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We implemented 2 generator config options in this PR (merged today): clientClassName and environmentEnumName. We can probably mention them here.

Copy link
Collaborator Author

@devalog devalog Aug 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I originally hid it from the left nav because there weren't any config options listed. I just added info on the clientClassName and environmentEnumName, and the page should appear in the preview link now!

Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
---
title: Publishing as a Swift package
description: How to publish the Fern Go SDK to the Go module proxy.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect description referencing "Go"

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed!

---

Publish your public-facing Fern Swift SDK as a Swift package distributed via Git. After following the steps on this page, you'll have a versioned package that developers can install using Swift Package Manager.

<Markdown src="/products/sdks/snippets/setup-fern-folder-callout.mdx"/>

## Configure `generators.yml`

<Steps>
<Step title="Configure `output` location">
Swift packages are distributed via Git repositories, so remove the auto-generated `output` and `config` properties. Instead, add the path to your GitHub repository:

```yaml {6-7} title="generators.yml"
groups:
swift-sdk:
generators:
- name: fernapi/fern-swift-sdk
version: 1.0.0
github:
repository: your-org/company-swift
```
</Step>
</Steps>

## Publish as a Swift package

At this point, you're ready to generate a release for your SDK.

<Steps>
<Step title="Generate your release">
Regenerate your SDK and publish it to your repository:

```bash
fern generate --group swift-sdk --version <version>
```

Local machine output will verify that the release is pushed to your repository and tagged with the version you specified.
</Step>

<Step title="Verify package availability">
Your Swift package is now available! Developers can add it to their projects by:

- **In Xcode**: File → Add Package Dependencies → Enter your repository URL
- **In Package.swift**: Add to dependencies array:

```swift
dependencies: [
.package(url: "https://github.com/<github-org>/<github-repo-name>", from: "<version>")
]
```

<Tip>
Unlike centralized registries, there's no separate "publishing" step required. Your package becomes available immediately once pushed to Git with proper tags.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd change "once pushed to Git" to "Once pushed to GitHub" or "Once pushed to a Git repo"

Git is the version control system. We currently support GitHub publishing only. There are other hosting providers like Gitlab and Bitbucket

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

e.g. can say something like "Unlike other languages that rely on centralized registries, Swift packages are available as soon as they’re tagged and pushed to a Git repository"

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, thanks!


You can optionally submit your package to the community-maintained [Swift Package Index](https://swiftpackageindex.com/) for better discoverability.
</Tip>
</Step>
</Steps>



62 changes: 62 additions & 0 deletions fern/products/sdks/overview/swift/quickstart.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
---
title: Swift quickstart
description: Get started quickly with the Fern Swift SDK.
---

Generate a Swift SDK by following the instructions on this page.

<Markdown src="/products/sdks/snippets/setup-fern-folder-callout.mdx"/>

<Steps>
<Markdown src="/products/sdks/snippets/pass-fern-check.mdx"/>

### Add the SDK generator

Run the following command to add the Swift SDK generator to `generators.yml`:

```bash
fern add fern-swift-sdk --group swift-sdk
```

<Note>
`swift-sdk` is the name of the `generators.yml` group that configures your Swift
SDK's output location and other metadata. You can customize this group name to
differentiate between multiple SDKs across different languages (e.g.,
`ruby-sdk`, etc) in your organization.
</Note>

This command adds the following `group` to `generators.yml`:

```yaml title="generators.yml"
swift-sdk: # group name
generators:
- name: fernapi/fern-swift-sdk
version: <Markdown src="/snippets/version-number-swift.mdx"/>
output:
location: local-file-system
path: ../sdks/swift
```

### Generate the SDK

Run the following command to generate your SDK:

```bash
fern generate --group swift-sdk
```

<Markdown src="/products/sdks/snippets/generate-sdk.mdx"/>

```bash
fern/ # created by fern init
sdks/ # created by fern generate --group swift-sdk
├─ swift
├─ Package.swift
└─ Sources
├─ ApiClient.swift
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to confirm: ApiClient.swift here isn’t fixed. For example, in the Chrt SDK, it’ll be ChrtClient.swift, since that’s set via generator config options (WIP). For others, it might be PetstoreClient.swift, etc.

When naming the root client class, we first check the generator config options. If no value is provided there, we fall back to the API name from the IR (inferred from the definition). ApiClient.swift only appears when the inferred name is Api.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed this to YourClient.swift

├─ Schemas/
├─ Public/
├─ Core/
└─ Resources/
```
</Steps>
14 changes: 14 additions & 0 deletions fern/products/sdks/sdks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,20 @@ navigation:
slug: changelog
- link: Customer showcase
href: https://buildwithfern.com/showcase#sdk-customers.ruby
- section: Swift
contents:
- page: Quickstart
path: ./overview/swift/quickstart.mdx
slug: quickstart
- page: Configuration
hidden: true
path: ./overview/swift/configuration.mdx
slug: configuration
- page: Publishing as a Swift package
path: ./overview/swift/publishing-to-swift-package-manager.mdx
slug: publishing
- changelog: ./overview/swift/changelog
slug: changelog
- section: Postman
contents:
- page: Quickstart
Expand Down