-
Notifications
You must be signed in to change notification settings - Fork 4
Add Swift quickstart and publishing guide (SDKs) #579
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
9c85331
326b50d
d50c054
b7a15b7
3bc0546
72bdf9b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 | ||
| 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. | ||
|
||
| --- | ||
|
|
||
| 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. | ||
|
||
|
|
||
| You can optionally submit your package to the community-maintained [Swift Package Index](https://swiftpackageindex.com/) for better discoverability. | ||
| </Tip> | ||
| </Step> | ||
| </Steps> | ||
|
|
||
|
|
||
|
|
||
| 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 | ||
|
||
| ├─ Schemas/ | ||
| ├─ Public/ | ||
| ├─ Core/ | ||
| └─ Resources/ | ||
| ``` | ||
| </Steps> | ||
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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):
clientClassNameandenvironmentEnumName. We can probably mention them here.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
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
clientClassNameandenvironmentEnumName, and the page should appear in the preview link now!