Skip to content

Commit 694a8cd

Browse files
feat(swift): generate Version.swift with sdkVersion constant (#14724)
* feat(swift-sdk): generate Version.swift with SDK version constant Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix(swift-sdk): use minor version bump 0.31.0 for feat changelog entry Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * fix(swift-sdk): make sdkVersion public and add seed test snapshots Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
1 parent 9b45e40 commit 694a8cd

124 files changed

Lines changed: 146 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

generators/swift/sdk/src/SdkGeneratorCli.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ export class SdkGeneratorCLI extends AbstractSwiftGeneratorCli<SdkCustomConfigSc
172172
this.generateSourceSchemaFiles(context);
173173
this.generateSourceRootClientFile(context);
174174
this.generateSourceEnvironmentFile(context);
175+
this.generateVersionFile(context);
175176
}
176177

177178
private async generateSourceAsIsFiles(context: SdkGeneratorContext): Promise<void> {
@@ -576,6 +577,18 @@ export class SdkGeneratorCLI extends AbstractSwiftGeneratorCli<SdkCustomConfigSc
576577
});
577578
}
578579

580+
private generateVersionFile(context: SdkGeneratorContext): void {
581+
const spmDetails = context.getSPMDetails();
582+
const version = spmDetails.minVersion;
583+
if (version != null) {
584+
context.project.addSourceAsIsFile({
585+
nameCandidateWithoutExtension: "Version",
586+
directory: RelativeFilePath.of(""),
587+
contents: `public let sdkVersion = "${version}"\n`
588+
});
589+
}
590+
}
591+
579592
private generateSourceEnvironmentFile(context: SdkGeneratorContext): void {
580593
if (context.ir.environments && context.ir.environments.environments.type === "singleBaseUrl") {
581594
const environmentSymbol = context.project.nameRegistry.getEnvironmentSymbolOrThrow();

generators/swift/sdk/versions.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# yaml-language-server: $schema=../../../fern-versions-yml.schema.json
22

3+
- version: 0.31.0
4+
changelogEntry:
5+
- summary: |
6+
Generate a `Version.swift` source file containing the SDK version
7+
string. This embeds the version in the generated source code for
8+
consistency with other generators and fixes auto-versioning for
9+
Swift SDKs.
10+
type: feat
11+
createdAt: "2026-04-07"
12+
irVersion: 61
13+
314
- version: 0.30.0
415
changelogEntry:
516
- summary: |

seed/swift-sdk/accept-header/Sources/Version.swift

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

seed/swift-sdk/alias-extends/Sources/Version.swift

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

seed/swift-sdk/alias/Sources/Version.swift

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

seed/swift-sdk/any-auth/Sources/Version.swift

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

seed/swift-sdk/api-wide-base-path/Sources/Version.swift

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

seed/swift-sdk/audiences/Sources/Version.swift

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

seed/swift-sdk/basic-auth-environment-variables/Sources/Version.swift

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

seed/swift-sdk/basic-auth-pw-omitted/Sources/Version.swift

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)