Skip to content

Commit cea2c86

Browse files
authored
Add Swift quickstart and publishing guide (SDKs) (#579)
1 parent 8baa503 commit cea2c86

File tree

5 files changed

+170
-0
lines changed

5 files changed

+170
-0
lines changed

fern/products/docs/pages/component-library/default-components/tooltips.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ description: 'Add interactive tooltips to your documentation.'
55

66
The Tooltips component provides a way to display additional information when users hover over an element. This is particularly useful for providing context or explanations without cluttering the interface.
77

8+
## Tooltips in CodeBlocks
9+
810
## Properties
911

1012
<ParamField path="data" type="object" required={true}>
@@ -135,3 +137,5 @@ const api = axios.create({
135137
`````
136138
</Tab>
137139
</Tabs>
140+
141+
## Tooltips for Text
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
title: Swift configuration
3+
description: Configuration options for the Fern Swift SDK.
4+
---
5+
6+
You can customize the behavior of the Swift SDK generator in `generators.yml`:
7+
8+
```yaml {7-8} title="generators.yml"
9+
default-group: local
10+
groups:
11+
local:
12+
generators:
13+
- name: fernapi/fern-swift-sdk
14+
version: <Markdown src="/snippets/version-number-swift.mdx"/>
15+
clientClassName: YourClientName
16+
environmentEnumName: YourCustomEnvironment
17+
```
18+
19+
## SDK Configuration Options
20+
21+
<ParamField path="clientClassName" type="string" required={false} toc={true}>
22+
The name of the generated client class. This allows you to customize the class name that users will instantiate when using your SDK.
23+
</ParamField>
24+
25+
<ParamField path="environmentEnumName" type="string" required={false} toc={true}>
26+
The name of the generated environment enum. This allows you to customize the enum name that defines your API environments (such as production, staging, development) and ensures consistent naming across SDK generations.
27+
</ParamField>
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
---
2+
title: Publishing as a Swift package
3+
description: How to publish the Fern Swift SDK as a Swift package
4+
---
5+
6+
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.
7+
8+
<Markdown src="/products/sdks/snippets/setup-fern-folder-callout.mdx"/>
9+
10+
## Configure `generators.yml`
11+
12+
<Steps>
13+
<Step title="Configure `output` location">
14+
Swift packages are distributed via Git repositories, so remove the auto-generated `output` and `config` properties. Instead, add the path to your GitHub repository:
15+
16+
```yaml {6-7} title="generators.yml"
17+
groups:
18+
swift-sdk:
19+
generators:
20+
- name: fernapi/fern-swift-sdk
21+
version: 1.0.0
22+
github:
23+
repository: your-org/company-swift
24+
```
25+
</Step>
26+
</Steps>
27+
28+
## Publish as a Swift package
29+
30+
At this point, you're ready to generate a release for your SDK.
31+
32+
<Steps>
33+
<Step title="Generate your release">
34+
Regenerate your SDK and publish it to your repository:
35+
36+
```bash
37+
fern generate --group swift-sdk --version <version>
38+
```
39+
40+
Local machine output will verify that the release is pushed to your repository and tagged with the version you specified.
41+
</Step>
42+
43+
<Step title="Verify package availability">
44+
Your Swift package is now available! Developers can add it to their projects by:
45+
46+
- **In Xcode**: File → Add Package Dependencies → Enter your repository URL
47+
- **In Package.swift**: Add to dependencies array:
48+
49+
```swift
50+
dependencies: [
51+
.package(url: "https://github.com/<github-org>/<github-repo-name>", from: "<version>")
52+
]
53+
```
54+
55+
<Tip>
56+
Unlike other languages that rely on centralized registries, Swift packages are available as soon as they’re tagged and pushed to a Git repository.
57+
58+
You can optionally submit your package to the community-maintained [Swift Package Index](https://swiftpackageindex.com/) for better discoverability.
59+
</Tip>
60+
</Step>
61+
</Steps>
62+
63+
64+
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
---
2+
title: Swift quickstart
3+
description: Get started quickly with the Fern Swift SDK.
4+
---
5+
6+
Generate a Swift SDK by following the instructions on this page.
7+
8+
<Markdown src="/products/sdks/snippets/setup-fern-folder-callout.mdx"/>
9+
10+
<Steps>
11+
<Markdown src="/products/sdks/snippets/pass-fern-check.mdx"/>
12+
13+
### Add the SDK generator
14+
15+
Run the following command to add the Swift SDK generator to `generators.yml`:
16+
17+
```bash
18+
fern add fern-swift-sdk --group swift-sdk
19+
```
20+
21+
<Note>
22+
`swift-sdk` is the name of the `generators.yml` group that configures your Swift
23+
SDK's output location and other metadata. You can customize this group name to
24+
differentiate between multiple SDKs across different languages (e.g.,
25+
`ruby-sdk`, etc) in your organization.
26+
</Note>
27+
28+
This command adds the following `group` to `generators.yml`:
29+
30+
```yaml title="generators.yml"
31+
swift-sdk: # group name
32+
generators:
33+
- name: fernapi/fern-swift-sdk
34+
version: <Markdown src="/snippets/version-number-swift.mdx"/>
35+
output:
36+
location: local-file-system
37+
path: ../sdks/swift
38+
```
39+
40+
### Generate the SDK
41+
42+
Run the following command to generate your SDK:
43+
44+
```bash
45+
fern generate --group swift-sdk
46+
```
47+
48+
<Markdown src="/products/sdks/snippets/generate-sdk.mdx"/>
49+
50+
```bash
51+
fern/ # created by fern init
52+
sdks/ # created by fern generate --group swift-sdk
53+
├─ swift
54+
├─ Package.swift
55+
└─ Sources
56+
├─ YourClient.swift
57+
├─ Schemas/
58+
├─ Public/
59+
├─ Core/
60+
└─ Resources/
61+
```
62+
</Steps>

fern/products/sdks/sdks.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,19 @@ navigation:
179179
slug: changelog
180180
- link: Customer showcase
181181
href: https://buildwithfern.com/showcase#sdk-customers.ruby
182+
- section: Swift
183+
contents:
184+
- page: Quickstart
185+
path: ./overview/swift/quickstart.mdx
186+
slug: quickstart
187+
- page: Configuration
188+
path: ./overview/swift/configuration.mdx
189+
slug: configuration
190+
- page: Publishing as a Swift package
191+
path: ./overview/swift/publishing-to-swift-package-manager.mdx
192+
slug: publishing
193+
- changelog: ./overview/swift/changelog
194+
slug: changelog
182195
- section: Postman
183196
contents:
184197
- page: Quickstart

0 commit comments

Comments
 (0)