Skip to content

Commit acbe91e

Browse files
committed
Custom Package.swift for Apple
1 parent 55c40dd commit acbe91e

File tree

6 files changed

+74
-7
lines changed

6 files changed

+74
-7
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
fail-fast: false
1414
matrix:
1515
php-version: ['8.2']
16-
sdk: [Android5Java17, Android14Java17, CLINode16, CLINode18, DartBeta, DartStable, Deno1193, Deno1303, DotNet60, DotNet70, FlutterStable, FlutterBeta, Go112, Go118, KotlinJava8, KotlinJava11, KotlinJava17, Node16, Node18, Node20, PHP74, PHP80, Python38, Python39, Python310, Ruby27, Ruby30, Ruby31, AppleSwift55, Swift55, WebChromium, WebNode]
16+
sdk: [Android5Java17, Android14Java17, CLINode16, CLINode18, DartBeta, DartStable, Deno1193, Deno1303, DotNet60, DotNet70, FlutterStable, FlutterBeta, Go112, Go118, KotlinJava8, KotlinJava11, KotlinJava17, Node16, Node18, Node20, PHP74, PHP80, Python38, Python39, Python310, Ruby27, Ruby30, Ruby31, AppleSwift56, Swift56, WebChromium, WebNode]
1717

1818
steps:
1919
- name: Checkout repository

src/SDK/Language/Apple.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function getFiles(): array
3333
[
3434
'scope' => 'default',
3535
'destination' => 'Package.swift',
36-
'template' => 'swift/Package.swift.twig',
36+
'template' => 'apple/Package.swift.twig',
3737
],
3838
[
3939
'scope' => 'method',

templates/apple/Package.swift.twig

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
// swift-tools-version:5.1
2+
3+
import PackageDescription
4+
5+
let package = Package(
6+
name: "{{spec.title | caseUcfirst}}",
7+
platforms: [
8+
.iOS("15.0"),
9+
.macOS("11.0"),
10+
.watchOS("7.0"),
11+
.tvOS("13.0"),
12+
],
13+
products: [
14+
.library(
15+
name: "{{spec.title | caseUcfirst}}",
16+
targets: [
17+
"{{spec.title | caseUcfirst}}",
18+
"{{spec.title | caseUcfirst}}Enums",
19+
"{{spec.title | caseUcfirst}}Models",
20+
"JSONCodable"
21+
]
22+
),
23+
],
24+
dependencies: [
25+
.package(url: "https://github.com/swift-server/async-http-client.git", from: "1.9.0"),
26+
.package(url: "https://github.com/apple/swift-nio.git", from: "2.32.0"),
27+
.package(url: "https://github.com/firebase/firebase-ios-sdk.git", from: "10.4.0")
28+
],
29+
targets: [
30+
.target(
31+
name: "{{spec.title | caseUcfirst}}",
32+
dependencies: [
33+
.product(name: "AsyncHTTPClient", package: "async-http-client"),
34+
.product(name: "NIOWebSocket", package: "swift-nio"),
35+
.product(name: "FirebaseMessaging", package: "firebase-ios-sdk"),
36+
{%~ if spec.definitions is not empty %}
37+
"{{spec.title | caseUcfirst}}Models",
38+
{%~ endif %}
39+
{%~ if spec.enums is not empty %}
40+
"{{spec.title | caseUcfirst}}Enums",
41+
{%~ endif %}
42+
"JSONCodable"
43+
]
44+
),
45+
{%~ if spec.definitions is not empty %}
46+
.target(
47+
name: "{{spec.title | caseUcfirst}}Models",
48+
dependencies: [
49+
"JSONCodable"
50+
]
51+
),
52+
{%~ endif %}
53+
{%~ if spec.enums is not empty %}
54+
.target(
55+
name: "{{spec.title | caseUcfirst}}Enums"
56+
),
57+
{%~ endif %}
58+
.target(
59+
name: "JSONCodable"
60+
),
61+
.testTarget(
62+
name: "{{spec.title | caseUcfirst}}Tests",
63+
dependencies: [
64+
"{{ spec.title | caseUcfirst }}"
65+
]
66+
)
67+
],
68+
swiftLanguageVersions: [.v5]
69+
)

templates/swift/Package.swift.twig

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,13 @@ let package = Package(
2424
dependencies: [
2525
.package(url: "https://github.com/swift-server/async-http-client.git", from: "1.9.0"),
2626
.package(url: "https://github.com/apple/swift-nio.git", from: "2.32.0"),
27-
.package(url: "https://github.com/firebase/firebase-ios-sdk.git", from: "10.4.0")
2827
],
2928
targets: [
3029
.target(
3130
name: "{{spec.title | caseUcfirst}}",
3231
dependencies: [
3332
.product(name: "AsyncHTTPClient", package: "async-http-client"),
3433
.product(name: "NIOWebSocket", package: "swift-nio"),
35-
.product(name: "FirebaseMessaging", package: "firebase-ios-sdk"),
3634
{%~ if spec.definitions is not empty %}
3735
"{{spec.title | caseUcfirst}}Models",
3836
{%~ endif %}

tests/AppleSwift55Test.php renamed to tests/AppleSwift56Test.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Tests;
44

5-
class AppleSwift55Test extends Base
5+
class AppleSwift56Test extends Base
66
{
77
protected string $sdkName = 'swift';
88
protected string $sdkPlatform = 'client';

tests/Swift55Test.php renamed to tests/Swift56Test.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Tests;
44

5-
class Swift55Test extends Base
5+
class Swift56Test extends Base
66
{
77
protected string $sdkName = 'swift';
88
protected string $sdkPlatform = 'server';
@@ -16,7 +16,7 @@ class Swift55Test extends Base
1616
'cp tests/languages/swift/Tests.swift tests/sdks/swift/Tests/AppwriteTests/Tests.swift',
1717
];
1818
protected string $command =
19-
'docker run --network="mockapi" --rm -v $(pwd):/app -w /app/tests/sdks/swift swiftarm/swift:5.5.2-focal-multi-arch swift test';
19+
'docker run --network="mockapi" --rm -v $(pwd):/app -w /app/tests/sdks/swift swift:5.6 swift test';
2020

2121
protected array $expectedOutput = [
2222
...Base::FOO_RESPONSES,

0 commit comments

Comments
 (0)