Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
128 commits
Select commit Hold shift + click to select a range
b7ee545
Update swift templates
Jul 19, 2021
915dccd
Fix swift file data type and service access
Jul 20, 2021
fa457c5
Update service parameters to remove name requirement, add NIO
Jul 20, 2021
86dca37
Add http shutdown to release native resources appropriately
Jul 20, 2021
358086e
Update client to use correct HTTP method
Jul 20, 2021
7311d72
Fix query params to string method
Jul 20, 2021
36f4e67
Add SwiftUI OAuth
Jul 20, 2021
eef405f
Add iOS language file
Jul 20, 2021
41c3a25
Add swift error file
Jul 20, 2021
a96555f
Update swift examples
Jul 20, 2021
2a8aa76
Add swift view extension for easier client OAuth registration
Jul 20, 2021
3cebb1b
WIP cookie handling
Jul 21, 2021
eb43951
Swift cookie fixes
Jul 26, 2021
d85e11c
WIP swift promises for async
Jul 26, 2021
6650aca
Call site swift promise fixes and add await
Jul 27, 2021
05fd4ed
Move `DispatchQueue` extension to it's own file
Jul 27, 2021
a67049f
Add method docs and remove typealiases to fix incorrect internal expo…
Jul 27, 2021
cd6ebd5
Fix error aliasing swift internal classes
Jul 27, 2021
ec07980
Add dispatch queue extension and future await to language file
Jul 27, 2021
6f715a6
Merge remote-tracking branch 'origin/master' into feat-swift-templates
abnegate Aug 3, 2021
956d507
Add swift-client, refactor swift to swift-server
abnegate Aug 3, 2021
f2ba34d
Add Swift example base project
abnegate Aug 3, 2021
1dffe77
Update swift docs
abnegate Aug 4, 2021
4ec077c
Migrate to more swift-like completions
abnegate Aug 4, 2021
3c4834d
Tidy up oauth, handle return to client without completing sign in
abnegate Aug 4, 2021
e125699
WIP add SDK interaction to example app with oauth
abnegate Aug 4, 2021
030f65a
WIP add swift test
abnegate Aug 4, 2021
4f7942f
Add URL type to Info.plist
abnegate Aug 4, 2021
6f0b079
Remove async and byte buffer extensions
abnegate Aug 5, 2021
bde2853
Add image download to swift example
abnegate Aug 5, 2021
d2c4406
Complete with error instead of throwing on client call exception
abnegate Aug 5, 2021
80f3a86
Update swift test
abnegate Aug 5, 2021
8a5b6f4
Add swift test to `SDKTest`
abnegate Aug 5, 2021
a0e5bcd
WIP update test to produce expected output, image upload test
abnegate Aug 6, 2021
f77b30e
Add cocoapod deploy GitHub action
abnegate Aug 10, 2021
3490f53
Add pod lint travis job
abnegate Aug 10, 2021
6ab8920
Add supported platforms to `Package.swift`
abnegate Aug 10, 2021
fe412ce
Update swift readme, shields + add cocoapods instruction
abnegate Aug 10, 2021
a6cf4ea
Add Swift `Query` class
abnegate Aug 10, 2021
fdaa052
Don't require attribute param name for swift query
abnegate Aug 10, 2021
3fa7fd2
Fix error handling and query class
abnegate Aug 10, 2021
5e87dd4
Add OAuth support for UIKit and AppKit
abnegate Aug 10, 2021
b638b2c
Move example to swift-ui
abnegate Aug 11, 2021
91f8d46
Add streaming delegate for large files
abnegate Aug 11, 2021
f498515
Add podspec
abnegate Aug 11, 2021
4431afb
Add UIKit example
abnegate Aug 11, 2021
9405880
Add streaming delegate to language file
abnegate Aug 11, 2021
e37d3c3
Merge remote-tracking branch 'origin/master' into feat-swift-templates
abnegate Sep 1, 2021
6cf9609
WIP fix UIKit app relaunch cookie storage
abnegate Sep 1, 2021
a084b47
Fix UIKit OAuth
abnegate Sep 3, 2021
8a0235e
WIP multipart/form-data storage upload
abnegate Sep 3, 2021
4a855a2
WIP multipart upload fix
abnegate Sep 6, 2021
7ee0812
Set self signed implementation
abnegate Sep 6, 2021
7231061
Merge remote-tracking branch 'origin/master' into feat-swift-templates
abnegate Sep 6, 2021
c8b336a
WIP add swift realtime models + service implementing swockets
abnegate Sep 13, 2021
ef95a37
Add codable JSON helpers
abnegate Sep 13, 2021
f3f6d98
Merge remote-tracking branch 'origin/master' into feat-swift-templates
abnegate Sep 13, 2021
63c1b12
Fix generics compilation issues for realtime service
abnegate Sep 14, 2021
1f7b803
WIP realtime integration testing
abnegate Sep 15, 2021
5035a25
Add swift comment twig filter
abnegate Sep 16, 2021
e03c10c
WIP implementation fixes
abnegate Sep 16, 2021
232c7ff
Open model class
abnegate Sep 16, 2021
905391c
Fix cookie storage between OAuth and other requests
abnegate Sep 21, 2021
521e708
WIP multi-part form fixes
abnegate Sep 21, 2021
326ec5f
Fix multipart uploads
abnegate Sep 22, 2021
8963dad
WIP fix tests
abnegate Sep 22, 2021
8dfbf28
Remove filename part param
abnegate Sep 22, 2021
9a1e21b
Fix non-string cast to string during multipart parse
abnegate Sep 23, 2021
be8f672
Fix tests
abnegate Sep 23, 2021
be921e8
Model accessibility fixes
abnegate Sep 23, 2021
be1f63d
Linux fixes
abnegate Sep 23, 2021
0518020
SwiftUI example updates
abnegate Sep 23, 2021
9a699f2
Doc fixes
abnegate Sep 27, 2021
4c6e2ed
Add missing example image picker
abnegate Sep 27, 2021
dff6e31
Add test to package
abnegate Sep 27, 2021
4950663
Use named parameters
abnegate Sep 27, 2021
176d3fd
Async connect
abnegate Sep 27, 2021
cfe43cb
Separate view model for SwiftUI example
abnegate Sep 28, 2021
fe6c964
Allow obj-c calls to service methods
abnegate Sep 28, 2021
2d01f3e
Use named parameters in client methods
abnegate Sep 28, 2021
c699d29
Realtime fixes
abnegate Sep 30, 2021
2edcd8d
Examples fixes
abnegate Oct 1, 2021
35c691d
Import WebSocket lib
abnegate Oct 1, 2021
1f5c434
SwiftUI examples updates
abnegate Oct 4, 2021
ae059db
UIKit example updates
abnegate Oct 4, 2021
1c4db96
Realtime updates
abnegate Oct 4, 2021
78765c0
Parameter fixes
abnegate Oct 4, 2021
ba98d01
Merge remote-tracking branch 'origin/master' into feat-swift-templates
abnegate Oct 4, 2021
ba44b77
WIP swift response models
abnegate Oct 5, 2021
020be46
Use positional parameter for service init
abnegate Oct 6, 2021
1ed9b2d
Swift response model module fixes
abnegate Oct 6, 2021
4c33411
Response model fix
abnegate Oct 7, 2021
3305dfa
Add swift cross-platform device info base
abnegate Oct 8, 2021
f53a0b4
Add swift cross platform package info base
abnegate Oct 8, 2021
7e4436f
Add swift cross platform shell mediator
abnegate Oct 8, 2021
fdfc4fc
Add Apple + WIP linux package infos, macOS + windows device infos
abnegate Oct 11, 2021
19a6987
Construct error from response message instead of entire response
abnegate Oct 12, 2021
f6f391f
Fix crash parsing bool responses
abnegate Oct 12, 2021
e006b99
Fix device infos
abnegate Oct 12, 2021
6b5acb6
WIP windows + linux device info fixes
abnegate Oct 12, 2021
01d6b9c
Add user-agent header
abnegate Oct 12, 2021
811b8d1
Update linux package info to read version file
abnegate Oct 12, 2021
ca0001f
Remove redundant comments
abnegate Oct 12, 2021
50df6a6
WIP Swift on linux build fixes
abnegate Oct 12, 2021
7c23f4e
Fix linux builds
abnegate Oct 13, 2021
dd5e44d
Remove redundant cast warnings
abnegate Oct 13, 2021
6bb7aeb
Fix docs for methods with parameters where none are required
abnegate Oct 13, 2021
d6f07d9
Update swift docs for response models
abnegate Oct 13, 2021
722c694
Fix swift docs
abnegate Oct 14, 2021
cf84abc
Fix all ambiguous error references
abnegate Oct 14, 2021
86610f7
Remove Appwrite references from templates
abnegate Oct 14, 2021
fc9d0a9
Update tests for response models
abnegate Oct 14, 2021
b08ca75
Add missing file to swiftui example
abnegate Oct 14, 2021
bb8571f
Revert invalid version
abnegate Oct 14, 2021
32acc59
Fix empty responses
abnegate Oct 14, 2021
692d616
Remove parameter defaults
abnegate Oct 14, 2021
50121f4
Remove redundant nullables
abnegate Oct 14, 2021
cb7ed20
Use empty bundle identifier for Swift server on macOS
abnegate Oct 15, 2021
b1d9de3
Remove query file
abnegate Oct 18, 2021
833c91d
Empty test file
abnegate Oct 18, 2021
7faba76
Merge remote-tracking branch 'origin/master' into feat-swift-templates
abnegate Oct 18, 2021
0fe34f9
Merge remote-tracking branch 'origin/master' into feat-swift-templates
abnegate Oct 18, 2021
089bd51
improve and fix realtime test
lohanidamodar Oct 18, 2021
5fc397d
Fix test whitelist
abnegate Oct 18, 2021
0c4ea69
Fix cookie passthrough for ws connection upgrade
abnegate Oct 20, 2021
438a636
Fix readme
abnegate Oct 20, 2021
8a32216
Fix syncShutdown called on event loop
abnegate Oct 21, 2021
5b4b720
Use print in server tests + remove deleting missing file
abnegate Oct 21, 2021
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
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,8 @@ examples/*

# exception to the rule
!examples/.gitkeep
.DS_Store
**/.DS_Store
templates/swift/example/.build
templates/swift/example/Example.xcodeproj/project.xcworkspace/xcuserdata
templates/swift/example/Example.xcodeproj/xcuserdata
**/xcuserdata
29 changes: 27 additions & 2 deletions example.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Appwrite\SDK\Language\Deno;
use Appwrite\SDK\Language\HTTP;
use Appwrite\SDK\Language\Swift;
use Appwrite\SDK\Language\SwiftClient;
use Appwrite\SDK\Language\DotNet;
use Appwrite\SDK\Language\Flutter;
use Appwrite\SDK\Language\Android;
Expand Down Expand Up @@ -269,7 +270,7 @@ function getSSLPage($url) {
$sdk->generate(__DIR__ . '/examples/go');


// Swift
// Swift (Server)
$sdk = new SDK(new Swift(), new Swagger2($spec));

$sdk
Expand All @@ -291,7 +292,31 @@ function getSSLPage($url) {
])
;

$sdk->generate(__DIR__ . '/examples/swift');
$sdk->generate(__DIR__ . '/examples/swift-server');

// Swift (Client)
$sdk = new SDK(new SwiftClient(), new Swagger2($spec));

$sdk
->setName('NAME')
->setDescription('Repo description goes here')
->setShortDescription('Repo short description goes here')
->setURL('https://example.com')
->setLogo('https://appwrite.io/v1/images/console.png')
->setLicenseContent('test test test')
->setWarning('**WORK IN PROGRESS - NOT READY FOR USAGE**')
->setChangelog('**CHANGELOG**')
->setVersion('0.0.1')
->setGitUserName('repoowner')
->setGitRepoName('reponame')
->setTwitter('appwrite_io')
->setDiscord('564160730845151244', 'https://appwrite.io/discord')
->setDefaultHeaders([
'X-Appwrite-Response-Format' => '0.7.0',
])
;

$sdk->generate(__DIR__ . '/examples/swift-client');

// DotNet
$sdk = new SDK(new DotNet(), new Swagger2($spec));
Expand Down
161 changes: 141 additions & 20 deletions src/SDK/Language/Swift.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,18 +119,18 @@ public function getFiles()
'template' => 'swift/Package.swift.twig',
'minify' => false,
],
[
'scope' => 'service',
'destination' => 'docs/{{service.name | caseLower}}.md',
'template' => 'swift/docs/service.md.twig',
'minify' => false,
],
[
'scope' => 'method',
'destination' => 'docs/examples/{{service.name | caseLower}}/{{method.name | caseDash}}.md',
'template' => 'swift/docs/example.md.twig',
'minify' => false,
],
[
'scope' => 'default',
'destination' => '/Tests/{{ spec.title | caseUcfirst}}Tests/Tests.swift',
'template' => 'swift/Tests/Tests.swift.twig',
'minify' => false,
],
[
'scope' => 'default',
'destination' => '/Sources/{{ spec.title | caseUcfirst}}/Client.swift',
Expand All @@ -139,16 +139,130 @@ public function getFiles()
],
[
'scope' => 'default',
'destination' => '/Sources/{{ spec.title | caseUcfirst}}/Service.swift',
'destination' => '/Sources/{{ spec.title | caseUcfirst}}/Models/{{ spec.title | caseUcfirst}}Error.swift',
'template' => '/swift/Sources/Models/Error.swift.twig',
'minify' => false,
],
[
'scope' => 'default',
'destination' => '/Sources/{{ spec.title | caseUcfirst}}/Models/File.swift',
'template' => 'swift/Sources/Models/File.swift.twig',
'minify' => false,
],
[
'scope' => 'default',
'destination' => '/Sources/{{ spec.title | caseUcfirst}}/Extensions/Codable+JSON.swift',
'template' => 'swift/Sources/Extensions/Codable+JSON.swift.twig',
'minify' => false,
],
[
'scope' => 'default',
'destination' => '/Sources/{{ spec.title | caseUcfirst}}/Extensions/Cookie+Codable.swift',
'template' => 'swift/Sources/Extensions/Cookie+Codable.swift.twig',
'minify' => false,
],
[
'scope' => 'default',
'destination' => '/Sources/{{ spec.title | caseUcfirst}}/Extensions/HTTPClientRequest+Cookies.swift',
'template' => 'swift/Sources/Extensions/HTTPClientRequest+Cookies.swift.twig',
'minify' => false,
],
[
'scope' => 'default',
'destination' => '/Sources/{{ spec.title | caseUcfirst}}/StreamingDelegate.swift',
'template' => 'swift/Sources/StreamingDelegate.swift.twig',
'minify' => false,
],
[
'scope' => 'default',
'destination' => '/Sources/{{ spec.title | caseUcfirst}}/Services/Service.swift',
'template' => 'swift/Sources/Service.swift.twig',
'minify' => false,
],
[
'scope' => 'default',
'destination' => '/Sources/{{ spec.title | caseUcfirst}}/DeviceInfo/iOS/iOSDeviceInfo.swift',
'template' => 'swift/Sources/DeviceInfo/iOS/iOSDeviceInfo.swift',
'minify' => false,
],
[
'scope' => 'default',
'destination' => '/Sources/{{ spec.title | caseUcfirst}}/DeviceInfo/iOS/UIDevice+ModelName.swift',
'template' => 'swift/Sources/DeviceInfo/iOS/UIDevice+ModelName.swift',
'minify' => false,
],
[
'scope' => 'default',
'destination' => '/Sources/{{ spec.title | caseUcfirst}}/DeviceInfo/Linux/LinuxDeviceInfo.swift',
'template' => 'swift/Sources/DeviceInfo/Linux/LinuxDeviceInfo.swift',
'minify' => false,
],
[
'scope' => 'default',
'destination' => '/Sources/{{ spec.title | caseUcfirst}}/DeviceInfo/MacOS/MacOSDeviceInfo.swift',
'template' => 'swift/Sources/DeviceInfo/MacOS/MacOSDeviceInfo.swift',
'minify' => false,
],
[
'scope' => 'default',
'destination' => '/Sources/{{ spec.title | caseUcfirst}}/DeviceInfo/MacOS/CwlSysCtl.swift',
'template' => 'swift/Sources/DeviceInfo/MacOS/CwlSysCtl.swift',
'minify' => false,
],
[
'scope' => 'default',
'destination' => '/Sources/{{ spec.title | caseUcfirst}}/DeviceInfo/Windows/WindowsDeviceInfo.swift',
'template' => 'swift/Sources/DeviceInfo/Windows/WindowsDeviceInfo.swift',
'minify' => false,
],
[
'scope' => 'default',
'destination' => '/Sources/{{ spec.title | caseUcfirst}}/DeviceInfo/OSDeviceInfo.swift',
'template' => 'swift/Sources/DeviceInfo/OSDeviceInfo.swift',
'minify' => false,
],
[
'scope' => 'default',
'destination' => '/Sources/{{ spec.title | caseUcfirst}}/PackageInfo/Apple/PackageInfo+Apple.swift',
'template' => 'swift/Sources/PackageInfo/Apple/PackageInfo+Apple.swift',
'minify' => false,
],
[
'scope' => 'default',
'destination' => '/Sources/{{ spec.title | caseUcfirst}}/PackageInfo/Linux/PackageInfo+Linux.swift',
'template' => 'swift/Sources/PackageInfo/Linux/PackageInfo+Linux.swift',
'minify' => false,
],
[
'scope' => 'default',
'destination' => '/Sources/{{ spec.title | caseUcfirst}}/PackageInfo/Windows/PackageInfo+Windows.swift',
'template' => 'swift/Sources/PackageInfo/Windows/PackageInfo+Windows.swift',
'minify' => false,
],
[
'scope' => 'default',
'destination' => '/Sources/{{ spec.title | caseUcfirst}}/PackageInfo/OSPackageInfo.swift',
'template' => 'swift/Sources/PackageInfo/OSPackageInfo.swift',
'minify' => false,
],
[
'scope' => 'default',
'destination' => '/Sources/{{ spec.title | caseUcfirst}}/PackageInfo/PackageInfo.swift',
'template' => 'swift/Sources/PackageInfo/PackageInfo.swift',
'minify' => false,
],
[
'scope' => 'service',
'destination' => '/Sources/{{ spec.title | caseUcfirst}}/Services/{{service.name | caseUcfirst}}.swift',
'template' => 'swift/Sources/Services/Service.swift.twig',
'minify' => false,
],
[
'scope' => 'definition',
'destination' => '/Sources/{{ spec.title | caseUcfirst}}Models/{{ definition.name | caseUcfirst }}.swift',
'template' => '/swift/Sources/Models/Model.swift.twig',
'minify' => false,
],
];
}

Expand All @@ -161,19 +275,18 @@ public function getTypeName($type)
switch ($type) {
case self::TYPE_INTEGER:
return 'Int';
break;
case self::TYPE_NUMBER:
return 'Double';
case self::TYPE_STRING:
return 'String';
break;
case self::TYPE_FILE:
return 'Array<Any>';
break;
return 'File';
case self::TYPE_BOOLEAN:
return 'Bool';
break;
case self::TYPE_ARRAY:
return "Array<Any>";
break;
return '[Any]';
case self::TYPE_OBJECT:
return 'Any';
}

return $type;
Expand All @@ -197,36 +310,44 @@ public function getParamDefault(array $param)

if(empty($default) && $default !== 0 && $default !== false) {
switch ($type) {
case self::TYPE_NUMBER:
case self::TYPE_INTEGER:
case self::TYPE_NUMBER:
$output = "0";
break;
case self::TYPE_STRING:
$output .= "\"\"";
$output .= '""';
break;
case self::TYPE_BOOLEAN:
$output .= 'false';
break;
case self::TYPE_ARRAY:
$output .= '[]';
break;
case self::TYPE_OBJECT:
$output .= 'nil';
break;
default:
echo $type;
}
}
else {
switch ($type) {
case self::TYPE_NUMBER:
case self::TYPE_INTEGER:
$output .= $default;
break;
case self::TYPE_ARRAY:
$output .= $default;
case self::TYPE_NUMBER:
$output .= sprintf("%.1f",$default);
break;
case self::TYPE_BOOLEAN:
$output .= ($default) ? 'true' : 'false';
break;
case self::TYPE_STRING:
$output .= "\"{$default}\"";
break;
case self::TYPE_ARRAY:
case self::TYPE_OBJECT:
$output .= 'nil';
break;
}
}

Expand All @@ -248,7 +369,7 @@ public function getParamExample(array $param)
if(empty($example) && $example !== 0 && $example !== false) {
switch ($type) {
case self::TYPE_FILE:
$output .= "nil";
$output .= 'File(name: "image.jpg", buffer: yourByteBuffer)';
break;
case self::TYPE_NUMBER:
case self::TYPE_INTEGER:
Expand Down
Loading