{"id":13534153,"url":"https://github.com/appwrite/sdk-for-apple","last_synced_at":"2025-04-05T08:04:36.171Z","repository":{"id":40623389,"uuid":"409578805","full_name":"appwrite/sdk-for-apple","owner":"appwrite","description":"[READ-ONLY] Official Appwrite SDK for Apple Devices 🍎","archived":false,"fork":false,"pushed_at":"2025-03-11T05:45:57.000Z","size":483,"stargazers_count":106,"open_issues_count":4,"forks_count":30,"subscribers_count":20,"default_branch":"main","last_synced_at":"2025-03-29T07:03:07.191Z","etag":null,"topics":["hacktoberfest"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/appwrite.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-09-23T12:17:07.000Z","updated_at":"2025-03-12T07:09:07.000Z","dependencies_parsed_at":"2023-11-20T05:24:10.710Z","dependency_job_id":"ec7f456f-ff2d-4a2e-93a9-25a4eb77d12f","html_url":"https://github.com/appwrite/sdk-for-apple","commit_stats":null,"previous_names":[],"tags_count":31,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appwrite%2Fsdk-for-apple","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appwrite%2Fsdk-for-apple/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appwrite%2Fsdk-for-apple/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appwrite%2Fsdk-for-apple/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/appwrite","download_url":"https://codeload.github.com/appwrite/sdk-for-apple/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247305932,"owners_count":20917208,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hacktoberfest"],"created_at":"2024-08-01T07:01:27.059Z","updated_at":"2025-04-05T08:04:36.148Z","avatar_url":"https://github.com/appwrite.png","language":"Swift","readme":"# Appwrite Apple SDK\n\n![Swift Package Manager](https://img.shields.io/github/v/release/appwrite/sdk-for-apple.svg?color=green\u0026style=flat-square)\n![License](https://img.shields.io/github/license/appwrite/sdk-for-apple.svg?style=flat-square)\n![Version](https://img.shields.io/badge/api%20version-1.6.1-blue.svg?style=flat-square)\n[![Build Status](https://img.shields.io/travis/com/appwrite/sdk-generator?style=flat-square)](https://travis-ci.com/appwrite/sdk-generator)\n[![Twitter Account](https://img.shields.io/twitter/follow/appwrite?color=00acee\u0026label=twitter\u0026style=flat-square)](https://twitter.com/appwrite)\n[![Discord](https://img.shields.io/discord/564160730845151244?label=discord\u0026style=flat-square)](https://appwrite.io/discord)\n\n**This SDK is compatible with Appwrite server version 1.6.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-apple/releases).**\n\nAppwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the Apple SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)\n\n![Appwrite](https://github.com/appwrite/appwrite/raw/main/public/images/github.png)\n\n## Installation\n\n### Xcode with Swift Package Manager\n\nThe Appwrite Swift SDK is available via Swift Package Manager. In order to use the Appwrite Swift SDK from Xcode, select File \u003e **Add Packages**\n\nIn the dialog that appears, enter the Appwrite Swift SDK [package URL](git@github.com:appwrite/sdk-for-apple.git) in the search field. Once found, select `sdk-for-apple`.\n\nOn the right, select your version rules and ensure your desired target is selected in the **Add to Project** field.\n\nNow click add package and you're done!\n\n### Swift Package Manager\n\nAdd the package to your `Package.swift` dependencies:\n\n```swift\n    dependencies: [\n        .package(url: \"git@github.com:appwrite/sdk-for-apple.git\", from: \"9.0.0\"),\n    ],\n```\n\nThen add it to your target:\n\n```swift\n    targets: [\n        .target(\n            name: \"YourAppTarget\",\n            dependencies: [\n                .product(name: \"\", package: \"sdk-for-apple\")\n            ]\n        ),\n```\n\n\n## Getting Started\n\n### Add your Apple Platform\nTo initialize your SDK and start interacting with Appwrite services, you need to add a new Apple platform to your project. To add a new platform, go to your Appwrite console, select your project (create one if you haven't already), and click the 'Add Platform' button on the project Dashboard.\n\nFrom the options, choose to add a new **iOS**, **macOS**, **watchOS** or **tvOS** platform and add your app credentials.\n\nAdd your app \u003cu\u003ename\u003c/u\u003e and \u003cu\u003ebundle identifier\u003c/u\u003e. Your bundle identifier can be found in your Xcode project file or your `Info.plist` file. By registering a new platform, you are allowing your app to communicate with the Appwrite API.\n\n### Registering URL schemes\n\nIn order to capture the Appwrite OAuth callback url, the following URL scheme needs to be added to project. You can add this from Xcode by selecting your project file, then the target you wish to use OAuth with. From the `Info` tab, expand the `URL types` section and add your Appwrite instance domain for the `Identifier`, and `appwrite-callback-[PROJECT-ID]` for the `URL scheme`. Be sure to replace the **[PROJECT_ID]** string with your actual Appwrite project ID. You can find your Appwrite project ID in your project settings screen in the console. Alternatively, you can add the following block directly to your targets `Info.plist` file:\n\n```xml\n\u003ckey\u003eCFBundleURLTypes\u003c/key\u003e\n\u003carray\u003e\n\u003cdict\u003e\n    \u003ckey\u003eCFBundleTypeRole\u003c/key\u003e\n    \u003cstring\u003eEditor\u003c/string\u003e\n    \u003ckey\u003eCFBundleURLName\u003c/key\u003e\n    \u003cstring\u003eio.appwrite\u003c/string\u003e\n    \u003ckey\u003eCFBundleURLSchemes\u003c/key\u003e\n    \u003carray\u003e\n        \u003cstring\u003eappwrite-callback-[PROJECT-ID]\u003c/string\u003e\n    \u003c/array\u003e\n\u003c/dict\u003e\n\u003c/array\u003e\n```\n\nNext we need to add a hook to save cookies when our app is opened by its callback URL.\n\n### Registering an OAuth handler view\n\n\u003e If you're using UIKit, you can skip this section.\n\nIn SwiftUI this is as simple as ensuring `.registerOAuthHandler()` is called on the `View` you want to invoke an OAuth request from.\n\n### Updating the SceneDelegate for UIKit\n\n\u003e If you're using SwiftUI, you can skip this section.\n\nFor UIKit, you need to add the following function to your `SceneDelegate.swift`. If you have already defined this function, you can just add the contents from below.\n\n```swift\n    func scene(_ scene: UIScene, openURLContexts URLContexts: Set\u003cUIOpenURLContext\u003e) {\n        guard let url = URLContexts.first?.url,\n            url.absoluteString.contains(\"appwrite-callback\") else {\n            return\n        }\n        WebAuthComponent.handleIncomingCookie(from: url)\n    }\n```\n\n### Init your SDK\n\nInitialize your SDK with your Appwrite server API endpoint and project ID which can be found in your project settings page.\n\n```swift\nimport Appwrite\n\nfunc main() {\n    let client = Client()\n        .setEndpoint(\"http://[HOSTNAME_OR_IP]/v1\") // Your API Endpoint\n        .setProject(\"5df5acd0d48c2\") // Your project ID\n        .setSelfSigned() // Use only on dev mode with a self-signed SSL cert\n}\n```\n\n### Make Your First Request\n\nOnce your SDK object is initialized, create any of the Appwrite service objects and choose any request to send. Full documentation for any service method you would like to use can be found in your SDK documentation or in the [API References](https://appwrite.io/docs) section.\n\n```swift\nlet account = Account(client)\n\ndo {\n    let user = try await account.create(\n        userId: ID.unique(),\n        email: \"email@example.com\",\n        password: \"password\",\n        name: \"Walter O'Brien\"\n    )\n    print(String(describing: user.toMap()))\n} catch {\n    print(error.localizedDescription)\n}\n```\n\n### Full Example\n\n```swift\nimport Appwrite\n\nfunc main() {\n    let client = Client()\n        .setEndpoint(\"https://[HOSTNAME_OR_IP]/v1\") // Your API Endpoint\n        .setProject(\"5df5acd0d48c2\") // Your project ID\n        .setSelfSigned() // Use only on dev mode with a self-signed SSL cert\n\n    let account = Account(client)\n    \n    do {\n        let user = try await account.create(\n            userId: ID.unique(),\n            email: \"email@example.com\",\n            password: \"password\",\n            name: \"Walter O'Brien\"\n        )\n        print(String(describing: account.toMap()))\n    } catch {\n        print(error.localizedDescription)\n    }\n}\n```\n\n### Error Handling\n\nWhen an error occurs, the Appwrite Apple SDK throws an `AppwriteError` object with `message` and `code` properties. You can handle any errors in a catch block and present the `message` or `localizedDescription` to the user or handle it yourself based on the provided error information. Below is an example.\n\n```swift\nimport Appwrite\n\nfunc main() {\n    let account = Account(client)\n    \n    do {\n        let user = try await account.get()\n        print(String(describing: user.toMap()))\n    } catch {\n        print(error.localizedDescription)\n    }\n}\n```\n\n### Learn more\n\nYou can use the following resources to learn more and get help\n\n- 🚀 [Getting Started Tutorial](https://appwrite.io/docs/getting-started-for-server)\n- 📜 [Appwrite Docs](https://appwrite.io/docs)\n- 💬 [Discord Community](https://appwrite.io/discord)\n- 🚂 [Appwrite Swift Playground](https://github.com/appwrite/playground-for-swift-server)\n\n\n## Contribution\n\nThis library is auto-generated by Appwrite custom [SDK Generator](https://github.com/appwrite/sdk-generator). To learn more about how you can help us improve this SDK, please check the [contribution guide](https://github.com/appwrite/sdk-generator/blob/master/CONTRIBUTING.md) before sending a pull-request.\n\n## License\n\nPlease see the [BSD-3-Clause license](https://raw.githubusercontent.com/appwrite/appwrite/master/LICENSE) file for more information.","funding_links":[],"categories":["SDK","Swift"],"sub_categories":["Official Appwrite SDKs"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fappwrite%2Fsdk-for-apple","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fappwrite%2Fsdk-for-apple","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fappwrite%2Fsdk-for-apple/lists"}