{"id":32148952,"url":"https://github.com/contentstack/contentstack-swift","last_synced_at":"2026-02-21T03:02:35.693Z","repository":{"id":48636169,"uuid":"211842880","full_name":"contentstack/contentstack-swift","owner":"contentstack","description":"Swift SDK for Contentstack’s Content Delivery API","archived":false,"fork":false,"pushed_at":"2026-02-04T09:36:02.000Z","size":599,"stargazers_count":3,"open_issues_count":1,"forks_count":3,"subscribers_count":10,"default_branch":"master","last_synced_at":"2026-02-04T21:57:19.385Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/contentstack.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":"CODEOWNERS","security":"SECURITY.md","support":"Supporting Files/Info.plist","governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2019-09-30T11:19:10.000Z","updated_at":"2026-01-12T08:05:42.000Z","dependencies_parsed_at":"2024-02-27T08:03:30.597Z","dependency_job_id":"82c7d08f-15dc-4cb5-ba02-01a7d49851bd","html_url":"https://github.com/contentstack/contentstack-swift","commit_stats":{"total_commits":87,"total_committers":4,"mean_commits":21.75,"dds":"0.24137931034482762","last_synced_commit":"36c92e3c3951ada67820f2742418455f4aa0365c"},"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"purl":"pkg:github/contentstack/contentstack-swift","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/contentstack%2Fcontentstack-swift","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/contentstack%2Fcontentstack-swift/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/contentstack%2Fcontentstack-swift/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/contentstack%2Fcontentstack-swift/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/contentstack","download_url":"https://codeload.github.com/contentstack/contentstack-swift/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/contentstack%2Fcontentstack-swift/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29672264,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-21T00:11:43.526Z","status":"online","status_checked_at":"2026-02-21T02:00:07.432Z","response_time":107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2025-10-21T09:25:59.168Z","updated_at":"2026-02-21T03:02:35.687Z","avatar_url":"https://github.com/contentstack.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ![Contentstack](https://www.contentstack.com/docs/static/images/contentstack.png)\n\n# Contentstack Swift SDK\n![Contentstack CI](https://github.com/contentstack/contentstack-swift/workflows/Contentstack%20CI/badge.svg)\n\n\nContentstack is a headless CMS with an API-first approach. It is a CMS that developers can use to build powerful cross-platform applications in their favorite languages. Build your application frontend, and Contentstack will take care of the rest. [Read More](https://www.contentstack.com/).\n\nContentstack provides iOS SDK to build application on top of iOS. Given below is the detailed guide and helpful resources to get started with our iOS SDK.\n\n\n### Prerequisite\n\nLatest Xcode and Mac OS X\n\n\n### Setup and Installation\n\nTo use this SDK on iOS platform, you will have to install the SDK according to the steps given below.\n\n##### CocoaPods\n\n1. Add the following line to your Podfile:\n2. pod 'ContentstackSwift'\n3. Run pod install, and you should now have the latest Contentstack release.\n\n##### Import Header/Module   \n\n ```sh\n import ContentstackSwift\n ```\n### Key Concepts for using Contentstack\n\n#### Stack\n\nA stack is like a container that holds the content of your app. Learn more about [Stacks](https://www.contentstack.com/docs/guide/stack).\n\n#### Content Type\n\nContent type lets you define the structure or blueprint of a page or a section of your digital property. It is a form-like page that gives Content Managers an interface to input and upload content. [Read more](https://www.contentstack.com/docs/guide/content-types).\n\n#### Entry\n\nAn entry is the actual piece of content created using one of the defined content types. Learn more about [Entries](https://www.contentstack.com/docs/guide/content-management#working-with-entries).\n\n\n#### Asset\n\n\nAssets refer to all the media files (images, videos, PDFs, audio files, and so on) uploaded to Contentstack. These files can be used in multiple entries. Read more about [Assets](https://www.contentstack.com/docs/guide/content-management#working-with-assets).\n\n\n#### Environment\n\nA publishing environment corresponds to one or more deployment servers or a content delivery destination where the entries need to be published. Learn how to work with [Environments](https://www.contentstack.com/docs/guide/environments).\n\n### Contentstack iOS SDK: 5-minute Quickstart\n\n#### Initializing your SDK\n\nTo start using the SDK in your application, you will need to initialize the stack by providing the required keys and values associated with them:\n```\n  let stack:Stack = Contentstack.stack(apiKey: API_KEY, deliveryToken: DELIVERY_TOKEN, environment: ENVIRONMENT)\n```\n\nTo get the api credentials mentioned above, you need to log into your Contentstack account and then in your top panel navigation, go to Settings -\u0026gt; Stack to view both your API Key and your Delivery Token\n\nThe stack object that is returned is a Contentstack client object, which can be used to initialize different modules and make queries against our [Content Delivery API](https://contentstack.com/docs/apis/content-delivery-api/). The initialization process for each module is explained in the following section.\n\n\n#### Querying content from your stack\n\nTo fetch all entries of of a content type, use the query given below:\n\n ```\n let stack = Contentstack.stack(apiKey: apiKey,\n             deliveryToken: deliveryToken,\n             environment: environment)\n\n stack.contentType(uid: contentTypeUID).entry().query()\n    .find { (result: Result\u003cContentstackResponse\u003cEntryModel\u003e, Error\u003e, response: ResponseType) in\n      switch result {\n      case .success(let contentstackResponse):\n          // Contentstack response with AssetModel array in items.\n      case .failure(let error):\n          //Error Message\n      }\n  }\n ```\n\nTo fetch a specific entry from a content type, use the following query:\n\n ```\n  let stack = Contentstack.stack(apiKey: apiKey,\n              deliveryToken: deliveryToken,\n              environment: environment)\n \n  stack.contentType(uid: contentTypeUID).entry(uid: UID)\n  .fetch { (result: Result\u003cEntryModel, Error\u003e, response: ResponseType) in\n     switch result {\n     case .success(let model):\n          //Model retrive from API\n     case .failure(let error):\n          //Error Message\n     }\n  }\n ```\n### Advanced Queries\n\nYou can query for content types, entries, assets and more using our iOS API Reference.\n\n[iOS API Reference Doc](https://www.contentstack.com/docs/platforms/swift/api-reference/)\n\n### Working with Images\n\nWe have introduced Image Delivery APIs that let you retrieve images and then manipulate and optimize them for your digital properties. It lets you perform a host of other actions such as crop, trim, resize, rotate, overlay, and so on.\n\nFor example, if you want to crop an image (with width as 300 and height as 400), you simply need to append query parameters at the end of the image URL, such as, https://images.contentstack.io/v3/assets/uid_136download?crop=300,400. There are several more parameters that you can use for your images.\n\n[Read Image Delivery API documentation](https://www.contentstack.com/docs/developers/apis/image-delivery-api/).\n\nYou can use the Image Delivery API functions in this SDK as well. Here are a few examples of its usage in the SDK.\n\n ```\n /* set the image quality to 100 */\n let quality: UInt = 100\n let imageTransform = ImageTransform().qualiy(quality)\n let url = try imageURL.url(with: imageTransform)\n\n /* resize the image by specifying width and height */\n let width: UInt = 100\n let height: UInt = 100\n let urlboth = try imageURL\n     .url(with: makeImageTransformSUT()\n         .resize(\n             Resize(size:\n                 Size(width: width, height: height)\n         )\n     )\n  )\n ```\n[iOS API Reference Doc](https://www.contentstack.com/docs/platforms/swift/api-reference/)\n\n\n### Using the Sync API with iOS SDK\nThe Sync API takes care of syncing your Contentstack data with your app and ensures that the data is always up-to-date by providing delta updates. Contentstack’s iOS SDK supports Sync API, which you can use to build powerful apps. Read through to understand how to use the Sync API with Contentstack iOS SDK.\n\n#### Initial Sync\nThe Initial Sync process performs a complete sync of your app data. It returns all the published entries and assets of the specified stack in response.\n\nTo start the Initial Sync process, use the syncStack method.\n\n ```\nlet stack = Contentstack.stack(apiKey: apiKey,\n              deliveryToken: deliveryToken,\n              environment: environment)\n \nstack.sync(then: { (result: Result\u003cSyncStack, Error\u003e) in\n switch result {\n case .success(let syncStack):\n      let items = syncStack.items\n      \n      //error for any error description\n      //syncStack for SyncStack\n      //syncStack.syncToken: contains token for next sync Store this token For next sync\n      //syncStack.paginationToken: contains token for next sync page this token for next sync\n      //syncStack.items: contains sync data\n      If let token = syncStack.paginationToken {\n          UserDefault.standard.setValue(token, forKey:\"PaginationToken\")\n      }else if let token = syncStack.syncToken {\n          UserDefault.standard.setValue(token, forKey:\"SyncToken\")\n      }\n\n case .failure(let error):\n      print(error)\n }\n})\n ```\n\nThe response also contains a sync token, which you need to store, since this token is used to get subsequent delta updates later, as shown in the Subsequent Sync section below. \n\nYou can also fetch custom results in initial sync by using [advanced sync queries](#). \n\n\n#### Sync Pagination\nIf the result of the initial sync (or subsequent sync) contains more than 100 records, the response would be paginated. It provides pagination token in the response. However, you don’t have to use the pagination token manually to get the next batch; the SDK does that automatically, until the sync is complete. \n\nPagination token can be used in case you want to fetch only selected batches. It is especially useful if the sync process is interrupted midway (due to network issues, etc.). In such cases, this token can be used to restart the sync process from where it was interrupted.\n\n ```\nlet stack = Contentstack.stack(apiKey: apiKey,\n          deliveryToken: deliveryToken,\n          environment: environment)\n\nlet syncStack = SyncStack(paginationToken: paginationToken)\n\nstack.sync(syncStack, then: { (result: Result\u003cSyncStack, Error\u003e) in\n switch result {\n case .success(let syncStack):\n      let items = syncStack.items\n      \n      //error for any error description\n      //syncStack for SyncStack\n      //syncStack.syncToken: contains token for next sync Store this token For next sync\n      //syncStack.paginationToken: contains token for next sync page this token for next sync\n      //syncStack.items: contains sync data\n      If let token = syncStack.paginationToken {\n          UserDefault.standard.setValue(token, forKey:\"PaginationToken\")\n      }else if let token = syncStack.syncToken {\n          UserDefault.standard.setValue(token, forKey:\"SyncToken\")\n      }\n\n case .failure(let error):\n      print(error)\n }\n})\n ```\n \n#### Subsequent Sync\nYou can use the sync token (that you receive after initial sync) to get the updated content next time. The sync token fetches only the content that was added after your last sync, and the details of the content that was deleted or updated.\n\n ```\nlet stack = Contentstack.stack(apiKey: apiKey,\n          deliveryToken: deliveryToken,\n          environment: environment)\n\nlet syncStack = SyncStack(syncToken: syncToken)\n\nstack.sync(syncStack, then: { (result: Result\u003cSyncStack, Error\u003e) in\n switch result {\n case .success(let syncStack):\n      let items = syncStack.items\n      \n      //error for any error description\n      //syncStack for SyncStack\n      //syncStack.syncToken: contains token for next sync Store this token For next sync\n      //syncStack.paginationToken: contains token for next sync page this token for next sync\n      //syncStack.items: contains sync data\n      If let token = syncStack.paginationToken {\n          UserDefault.standard.setValue(token, forKey:\"PaginationToken\")\n      }else if let token = syncStack.syncToken {\n          UserDefault.standard.setValue(token, forKey:\"SyncToken\")\n      }\n\n case .failure(let error):\n      print(error)\n }\n})\n ```\n\n#### Advanced sync queries\nYou can use advanced sync queries to fetch filtered results. Let's look at them in detail.\n\n##### Initial sync from specific date\nFor initializing sync from a specific date, you can specify the date using the ```sync``` parameters.\n ```\nlet stack = Contentstack.stack(apiKey: apiKey,\n          deliveryToken: deliveryToken,\n          environment: environment)\n\nlet syncStack = SyncStack(syncToken: syncToken)\n\nstack.sync(syncTypes: [.startFrom(date)], then: { (result: Result\u003cSyncStack, Error\u003e) in\n switch result {\n case .success(let syncStack):\n      let items = syncStack.items\n      \n      //error for any error description\n      //syncStack for SyncStack\n      //syncStack.syncToken: contains token for next sync Store this token For next sync\n      //syncStack.paginationToken: contains token for next sync page this token for next sync\n      //syncStack.items: contains sync data\n      If let token = syncStack.paginationToken {\n          UserDefault.standard.setValue(token, forKey:\"PaginationToken\")\n      }else if let token = syncStack.syncToken {\n          UserDefault.standard.setValue(token, forKey:\"SyncToken\")\n      }\n\n case .failure(let error):\n      print(error)\n }\n})\n ```\n ##### Initial sync of specific content types\n You can also initialize sync with entries of only specific content types. To do this, use syncOnly and specify the content type UID as its value.\n\n However, if you do this, the subsequent syncs will only include the entries of the specified content types.\n  ```\n let stack = Contentstack.stack(apiKey: apiKey,\n           deliveryToken: deliveryToken,\n           environment: environment)\n\n let syncStack = SyncStack(syncToken: syncToken)\n\n stack.sync(syncTypes: [.contentType(\"contentTypeUID\")], then: { (result: Result\u003cSyncStack, Error\u003e) in\n  switch result {\n  case .success(let syncStack):\n       let items = syncStack.items\n       \n       //error for any error description\n       //syncStack for SyncStack\n       //syncStack.syncToken: contains token for next sync Store this token For next sync\n       //syncStack.paginationToken: contains token for next sync page this token for next sync\n       //syncStack.items: contains sync data\n       If let token = syncStack.paginationToken {\n           UserDefault.standard.setValue(token, forKey:\"PaginationToken\")\n       }else if let token = syncStack.syncToken {\n           UserDefault.standard.setValue(token, forKey:\"SyncToken\")\n       }\n\n  case .failure(let error):\n       print(error)\n  }\n })\n  ```\n##### Initial sync with specific language\nYou can also initialize sync with entries of only specific locales. To do this, use sync and specify the locale code as its value.\n\nHowever, if you do this, the subsequent syncs will only include the entries of the specified locales.\n\n ```\nlet stack = Contentstack.stack(apiKey: apiKey,\n          deliveryToken: deliveryToken,\n          environment: environment)\n\nlet syncStack = SyncStack(syncToken: syncToken)\n\nstack.sync(syncTypes: [.locale(\"en-gb\")], then: { (result: Result\u003cSyncStack, Error\u003e) in\n switch result {\n case .success(let syncStack):\n      let items = syncStack.items\n      \n      //error for any error description\n      //syncStack for SyncStack\n      //syncStack.syncToken: contains token for next sync Store this token For next sync\n      //syncStack.paginationToken: contains token for next sync page this token for next sync\n      //syncStack.items: contains sync data\n      If let token = syncStack.paginationToken {\n          UserDefault.standard.setValue(token, forKey:\"PaginationToken\")\n      }else if let token = syncStack.syncToken {\n          UserDefault.standard.setValue(token, forKey:\"SyncToken\")\n      }\n\n case .failure(let error):\n      print(error)\n }\n})\n ```\n ##### Initial sync with publish type\n You can also initialize sync with entries and assets based on a specific publish type. The acceptable values are PublishType enums entryPublished, entryUnpublished, entryDeleted, assetPublished, assetUnpublished, assetDeleted, and contentTypeDeleted. To do this, use syncPublishType and specify the parameters.\n\n However, if you do this, the subsequent syncs will only include the entries of the specified publish type\n  ```\n let stack = Contentstack.stack(apiKey: apiKey,\n           deliveryToken: deliveryToken,\n           environment: environment)\n\n let syncStack = SyncStack(syncToken: syncToken)\n\n stack.sync(syncTypes: [.publishType(.assetPublished)], then: { (result: Result\u003cSyncStack, Error\u003e) in\n  switch result {\n  case .success(let syncStack):\n       let items = syncStack.items\n       \n       //error for any error description\n       //syncStack for SyncStack\n       //syncStack.syncToken: contains token for next sync Store this token For next sync\n       //syncStack.paginationToken: contains token for next sync page this token for next sync\n       //syncStack.items: contains sync data\n       If let token = syncStack.paginationToken {\n           UserDefault.standard.setValue(token, forKey:\"PaginationToken\")\n       }else if let token = syncStack.syncToken {\n           UserDefault.standard.setValue(token, forKey:\"SyncToken\")\n       }\n\n  case .failure(let error):\n       print(error)\n  }\n })\n  ```\n##### Initial sync with multiple parameters\nFor initializing sync with entries of specific content types, starting from specific date, use the snippet given below.\n\nNote that subsequent syncs will only include the entries of the specified content types.\n ```\nlet stack = Contentstack.stack(apiKey: apiKey,\n          deliveryToken: deliveryToken,\n          environment: environment)\n\nlet syncStack = SyncStack(syncToken: syncToken)\n\nstack.sync(syncTypes: [.locale(\"en-gb\"), .contentType(\"contentTypeUID\")], then: { (result: Result\u003cSyncStack, Error\u003e) in\n switch result {\n case .success(let syncStack):\n      let items = syncStack.items\n      \n      //error for any error description\n      //syncStack for SyncStack\n      //syncStack.syncToken: contains token for next sync Store this token For next sync\n      //syncStack.paginationToken: contains token for next sync page this token for next sync\n      //syncStack.items: contains sync data\n      If let token = syncStack.paginationToken {\n          UserDefault.standard.setValue(token, forKey:\"PaginationToken\")\n      }else if let token = syncStack.syncToken {\n          UserDefault.standard.setValue(token, forKey:\"SyncToken\")\n      }\n\n case .failure(let error):\n      print(error)\n }\n})\n ```\n\n### Helpful Links\n\n- [Contentstack Website](https://www.contentstack.com)\n- [Official Documentation](http://contentstack.com/docs)\n- [Content Delivery API Docs](https://contentstack.com/docs/apis/content-delivery-api/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcontentstack%2Fcontentstack-swift","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcontentstack%2Fcontentstack-swift","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcontentstack%2Fcontentstack-swift/lists"}