{"id":5015,"date":"2018-04-17T10:00:01","date_gmt":"2018-04-17T17:00:01","guid":{"rendered":"http:\/\/www.couchbase.com\/blog\/?p=5015"},"modified":"2025-06-13T21:37:10","modified_gmt":"2025-06-14T04:37:10","slug":"xcode-playground-couchbase-mobile","status":"publish","type":"post","link":"https:\/\/www.couchbase.com\/blog\/xcode-playground-couchbase-mobile\/","title":{"rendered":"Xcode Playground for Exploring Query API in Couchbase Lite 2.0"},"content":{"rendered":"<p>This post is a step-by-step guide for using an Xcode Playground for exploring the new querying API in Couchbase Mobile 2.0. The <a href=\"https:\/\/www.couchbase.com\/blog\/couchbase-mobile-2-0\/\">Couchbase Lite 2.0 Release<\/a> introduces a simplified query API based on <a href=\"https:\/\/www.couchbase.com\/products\/n1ql\/\">N1QL<\/a>, Couchbase\u2019s declarative query language that extends SQL for JSON. If you are familiar with SQLite, you will feel right at home with the new <em>Query Builder<\/em> interface . The query API is designed using the <a href=\"https:\/\/en.wikipedia.org\/wiki\/Fluent_interface\">Fluent API Design Pattern<\/a>, and it uses method cascading to read to like a Domain Specific Language <a href=\"https:\/\/en.wikipedia.org\/wiki\/Domain-specific_language\">(DSL)<\/a>. This makes the interface very intuitive and easy to understand.<\/p>\n<p>The Xcode Playground is an interactive environment that allows you to write and execute swift code immediately, and offers a convienent way to learn and explore APIs without having to create a full-blown Xcode App project. This is a perfect use case for exploring the Coucbase Lite 2.0 API. We will not be creating a playground here. We will be using one that we have put together specifically for Query API testing.<\/p>\n<p>While the Xcode playground demonstrates the queries in swift, given the unified nature of the QueryBuilder API across the various Couchbase Lite platforms, barring language specific idioms, you should be able to easily translate the queries to any of the other platform languages supported in Couchbase Lite. So, even if you are <em>not<\/em> a Swift developer, you should be able to leverage the Xcode playground for API exploration. This post makes no assumptions about your familiarity with Swift or iOS Development so even if you are a complete newbie to iOS development, you should be able to follow along. Of course, you would need a Mac!<\/p>\n<p>You can learn more about the QueryBuilder API in our <a href=\"https:\/\/developer.couchbase.com\/documentation\/mobile\/2.0\/couchbase-lite\/index.html\">API References<\/a> guide.<\/p>\n<p><!--more--><\/p>\n<h3 id=\"recommendedreading\">Recommended Reading<\/h3>\n<p>These blog posts discuss the various querying capabilities in detail<br \/>\n&#8211; <a href=\"https:\/\/www.couchbase.com\/blog\/sql-for-json-query-interface-couchbase-mobile\/\">Fundamentals of the Query API<\/a><br \/>\n&#8211; <a href=\"https:\/\/www.couchbase.com\/blog\/querying-array-collections-couchbase-mobile\/\">Query of Array Collections<\/a><br \/>\n&#8211; <a href=\"https:\/\/www.couchbase.com\/blog\/full-text-search-couchbase-mobile-2-0\/\">Full Text Search capabilities.<\/a><br \/>\n&#8211; <a href=\"https:\/\/www.couchbase.com\/blog\/join-queries-couchbase-mobile\/\">Basic JOIN Query<\/a><\/p>\n<h3 id=\"background\">Background<\/h3>\n<p>If you were using 1.x versions of Couchbase Mobile, you are probably familiar with <a href=\"https:\/\/developer.couchbase.com\/documentation\/mobile\/1.4\/training\/develop\/using-the-database\/index.html#query-documents\">Map-Views<\/a> for creating indexes and queries. In 2.0, you no longer have to create views and map functions! Instead, a simple interface allows you to create indexes and you can use a Query Builder interface to construct your queries. The new query interface is simpler to use and much more powerful in comparison.<\/p>\n<h3 id=\"tldr\">TL;DR<\/h3>\n<p>If you prefer, here is a video recording of everything that\u2019s discussed in this blog post<\/p>\n<p><iframe loading=\"lazy\" title=\"Xcode Playground for Testing &amp; Exploring Query APIs in Couchbase Mobile\" width=\"900\" height=\"675\" src=\"https:\/\/www.youtube.com\/embed\/9NA2OXdSiqA?feature=oembed&#038;enablejsapi=1&#038;origin=https:\/\/www.couchbase.com\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" allowfullscreen><\/iframe><\/p>\n<h3 id=\"pre-requisites\">Pre-requisites<\/h3>\n<ul>\n<li>Xcode 8.3.3+ , latest version downloadable from <a href=\"https:\/\/itunes.apple.com\/us\/app\/xcode\/id497799835?mt=12\">Mac App Store<\/a><\/li>\n<\/ul>\n<p>The Playground is compatible with Swift 3.1+<\/p>\n<h4 id=\"installation\">Installation<\/h4>\n<ul>\n<li>Clone the <em>couchbase-lite-ios-api-playground<\/em> repo from GitHub by running the following command from the terminal<\/li>\n<\/ul>\n<pre><code> $ git clone https:\/\/github.com\/couchbaselabs\/couchbase-lite-ios-api-playground<\/code><\/pre>\n<ul>\n<li>We will use <a href=\"https:\/\/github.com\/Carthage\/Carthage\">Carthage<\/a> to download and install CouchbaseLite. Carthage is a dependency management system for Cocoa Applications. Note that Couchbase Lite for iOS is <a href=\"https:\/\/developer.couchbase.com\/documentation\/mobile\/2.0\/couchbase-lite\/swift.html#getting-started\">distributed<\/a> through Cocoapods , Carthage or you can download it directly from our <a href=\"https:\/\/couchbase.com\/downloads\/\">Downloads<\/a> page. We will be using Carthage here.<br \/>\nIf you do not have Carthage, please follow these <a href=\"https:\/\/github.com\/Carthage\/Carthage#installing-carthage\">instructions<\/a> to install Carthage on your MacOS<\/li>\n<li>Verify your carthage installation by typing following command in your terminal window. The version of carthage installed will be displayed<\/li>\n<\/ul>\n<pre><code> $ carthage version<\/code><\/pre>\n<ul>\n<li>Switch to the folder containing the <a href=\"https:\/\/github.com\/Carthage\/Carthage\/blob\/master\/Documentation\/Artifacts.md#cartfile\"><em>Cartfile<\/em><\/a>. This is located in the <em>carthage<\/em> folder. The Cartfile specifies the project dependencies, which in our case is the Couchbase Lite framework.<\/li>\n<\/ul>\n<pre><code> $ cd \/path\/to\/couchbase-lite-ios-api-playground\/carthage<\/code><\/pre>\n<ul>\n<li>Download Couchbase Lite using Carthage. The version of Couchbase Lite used is specified in the <em>Cartfile<\/em>. We will use the <code>--no-build<\/code> option to specify that carthage should not build the source but should only check out the files from the specified GitHub repo. This saves time.<\/li>\n<\/ul>\n<pre><code> $ carthage update \u2013platform ios \u2013no-build<\/code><\/pre>\n<ul>\n<li>Verify that the Couchbase Lite framework was succesfully checked out by running this command in your terminal<\/li>\n<\/ul>\n<pre><code> $ cd \/path\/to\/couchbase-lite-ios-api-playground\/carthage\r\n $ ls -l Carthage\/Checkouts\/couchbase-lite-ios\/\r\n total 24\r\n -rw-r\u2013r\u2013 1 priya.rajagopal 141224203 957 Apr 11 17:06 CouchbaseLite.podspec\r\n drwxr-xr-x@ 6 priya.rajagopal 141224203 192 Apr 11 17:09 CouchbaseLite.xcodeproj\r\n -rw-r\u2013r\u2013 1 priya.rajagopal 141224203 987 Apr 11 17:06 CouchbaseLiteSwift.podspec\r\n -rw-r\u2013r\u2013 1 priya.rajagopal 141224203 10273 Apr 11 17:06 LICENSE\r\n drwxr-xr-x 117 priya.rajagopal 141224203 3744 Apr 11 17:06 Objective-C\r\n -rw-r\u2013r\u2013 1 priya.rajagopal 141224203 2426 Apr 11 17:06 README.md\r\n drwxr-xr-x 11 priya.rajagopal 141224203 352 Apr 11 17:06 Scripts\r\n drwxr-xr-x 70 priya.rajagopal 141224203 2240 Apr 11 17:06 Swift\r\n drwxr-xr-x 4 priya.rajagopal 141224203 128 Apr 11 17:06 docs\r\n drwxr-xr-x 4 priya.rajagopal 141224203 128 Apr 11 17:06 vendor\r\n drwxr-xr-x 13 priya.rajagopal 141224203 416 Apr 11 17:06 xcconfigs<\/code><\/pre>\n<h4 id=\"setup\">Setup<\/h4>\n<p>We will be using two pre-built Couchbase Lite databases to exercise our queries. In order for the Xcode Playground to be able to access these databases, they must be located in a special <em>\u201cShared Playground Data\u201d<\/em> folder within the <em>Documents<\/em> folder on your Mac.<br \/>\nThe following steps are required the first time you are setting up for Playground. Subseqently, you will have to follow these steps <em>only if<\/em> you are changing the database.<\/p>\n<ul>\n<li>Create a folder named \u201cShared Playground Data\u201d within your \u201cDocuments\u201d folder on your Mac (if one does not exist)<\/li>\n<\/ul>\n<pre><code> $ mkdir ~\/Documents\/Shared\\ Playground\\ Data\/<\/code><\/pre>\n<ul>\n<li>Copy the \u201ctravel-sample.cblite2\u201d folder that is pulled from the <em>couchbase-lite-ios-api-playground<\/em> repo into the \u201cShared Playground Data\u201d. This prebuilt database will be used for trying out the queries.<\/li>\n<\/ul>\n<pre><code> $ cd \/path\/to\/couchbase-lite-ios-api-playground\/\r\n $ cp -r travel-sample.cblite2 ~\/Documents\/Shared\\ Playground\\ Data\/<\/code><\/pre>\n<ul>\n<li>Copy the \u201cjoindb.cblite2\u201d folder folder that is pulled from the <em>couchbase-lite-ios-api-playground<\/em> repo into the \u201cShared Playground Data\u201d. This prebuilt database will be used for trying out the queries related to JOINs.<\/li>\n<\/ul>\n<pre><code> $ cd \/path\/to\/couchbase-lite-ios-api-playground\/\r\n $ cp -r joindb.cblite2 ~\/Documents\/Shared\\ Playground\\ Data\/<\/code><\/pre>\n<ul>\n<li>Verify that the files were copied succesfully by using this command<\/li>\n<\/ul>\n<pre><code> $ ls -l ~\/Documents\/Shared\\ Playground\\ Data\/<\/code><\/pre>\n<h4 id=\"exploringtheproject\">Exploring the Project<\/h4>\n<p>Earlier in this post, I mentioned that the Xcode Playground does not require a full-blown App Project. That is still true. However, in our case, we need to be able to build and link the <code>CouchbaseLite.framework<\/code> with the Playground. There may be other options but the way I did it was to create a dummy Xcode project called <em>CBLTestBed.xcodeproj<\/em> that includes the Playground as well as the <code>CouchbaseLite.xcodeproj<\/code>.<\/p>\n<p>So when I build the <em>CBLTestBed<\/em> project, it would build the CouchbaseLiteSwift framework that is then imported by the Playground. Let\u2019s examine this further.<\/p>\n<ul>\n<li>Open the <code>CBLTestBed.xcodeproj<\/code> using Xcode<\/li>\n<\/ul>\n<pre><code> $ cd \/path\/to\/couchbase-lite-ios-api-playground\/\r\n $ open CBLTestBed.xcodeproj\/<\/code><\/pre>\n<ul>\n<li>You shoule see <code>CBLQueryPlayground.playground<\/code> and <code>CouchbaseLite.xcodeproj<\/code> contained within the <code>CBLTestBed.xcodeproj<\/code><\/li>\n<\/ul>\n<figure><img decoding=\"async\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2018\/04\/exploring_project.png\" alt=\"\" \/><\/figure>\n<ul>\n<li>Let\u2019s examine the <code>CBLQueryPlayground.playground<\/code>. You should see several playground pages in your project explorer. You can begin with any Playground page but it would probably be most logical to begin with the \u201cToC\u201d page. This is the \u201cTable Of Contents\u201d and provides an entry point to other pages.<\/li>\n<li>Check \u201cRender Documentation\u201d checkbox in the Utilities Window to turn on rendering of the playground pages<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2018\/04\/pages.png\" alt=\"\" \/><\/li>\n<li>From the \u201cToC\u201d page, you can navigate to any of the other playground pages. Each playground page includes a set of Query examples that exercises the query API against the \u201ctravel-sample.cblite\u201d database or the \u201cjoindb.cblite\u201d database as appropriate. As discussed in the \u201cSetup\u201d section, these databases are located in the \u201c~\/Documents\/Shared\\ Playground\\ Data\/\u201d folder.<\/li>\n<li>Every Playground page follows the same pattern. We open the local database and then invoke functions that does the querying using the QueryBuilder API.<br \/>\nSo, this is the basic structure &#8230;.<\/li>\n<\/ul>\n<pre class=\"lang:swift decode:true\">do {\r\n   \/\/ Open or Create Couchbase Lite Database\r\n   if let db:Database = try createOrOpenDatabase() {\r\n      let results1 = try queryForDocumentsByTestingArrayContainment(db, limit: 5)\r\n      print(\"\\n*****\\nResponse to queryForDocumentsByTestingArrayContainment : \\n \\(results1)\")\r\n  }\r\n}\r\ncatch {\r\n   print (\"Exception is (error.localizedDescription)\")\r\n}<\/pre>\n<p>&nbsp;<\/p>\n<h4 id=\"buildandrun\">Build and Run<\/h4>\n<p>In order to be able to execute the Playground, you would have to first build the <em>CouchbaseLiteSwift<\/em> framework. You can do this by building the containing <code>CBLTestBed.xcodeproj<\/code>.<\/p>\n<ul>\n<li>Select the \u201cCBLTestBed\u201d scheme and select a simulator as target. Build the project using <em>Cmd-B<\/em>.<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2018\/04\/project_build.png\" alt=\"\" \/><\/li>\n<li>Once the project is succesfully built, you can execute a playground by clicking on the \u201cRun\u201d button<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2018\/04\/run_page.gif\" alt=\"\" \/><\/li>\n<li>The results should be displayed in the output console<\/li>\n<li>Of course, since this is a playground, you can also examine the results inline<\/li>\n<\/ul>\n<h4 id=\"exploringotherqueryoptions\">Exploring other Query Options<\/h4>\n<p>The queries provided with the sample playground are intended to be used as a reference. It should be straightforward to see that you can update the queries to explore other querying options.<\/p>\n<p>So, for instance, in example below, \u00a0change the \u201ctype\u201d property and \u201climit\u201d value to something else and see what happens to the results. You can add you own queries as well.<\/p>\n<pre class=\"lang:swift decode:true \">func queryForDocumentsOfSpecificTypeFromDB(_ db:Database,limit:Int = 10 ) throws -&gt; [Data]? {\r\n  let searchQuery = QueryBuilder\r\n     .select(SelectResult.all())\r\n     .from(DataSource.database(db))\r\n     .where(Expression.property(&amp;amp;quot;type&amp;amp;quot;).equalTo(Expression.string(&amp;amp;quot;hotel&amp;amp;quot;)))\r\n     .limit(Expression.int(limit))\r\n\r\n  var matches:[Data] = [Data]()\r\n  do {\r\n    for row in try searchQuery.execute() {\r\n        matches.append(row.toDictionary())\r\n    }\r\n }\r\n return matches\r\n}<\/pre>\n<p>&nbsp;<\/p>\n<h3 id=\"whatnext\">What Next<\/h3>\n<p>This blog post demonstrated the use of Xcode Playgrounds as a convienent way to explore and test the new query API in Couchbase Mobile 2.0. If you would like to add new queries, please submit a Github <a href=\"https:\/\/github.com\/couchbaselabs\/couchbase-lite-ios-api-playground\">PR<\/a>.<\/p>\n<p>If\u00a0you have questions or feedback, please leave a comment below or feel free to reach out to me at Twitter\u00a0<a href=\"https:\/\/twitter.com\/rajagp\">@rajagp<\/a>\u00a0or email me\u00a0<a href=\"mailto:priya.rajagopal@couchbase.com\">priya.rajagopal@couchbase.com<\/a>. \u00a0The\u00a0<a href=\"https:\/\/www.couchbase.com\/forums\/\">Couchbase Forums<\/a> are another good place to reach out with\u00a0questions.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This post is a step-by-step guide for using an Xcode Playground for exploring the new querying API in Couchbase Mobile 2.0. The Couchbase Lite 2.0 Release introduces a simplified query API based on N1QL, Couchbase\u2019s declarative query language that extends [&hellip;]<\/p>\n","protected":false},"author":1423,"featured_media":11842,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[2370,1815,7667,1810,2165,9410,1812],"tags":[1536,1909],"ppma_author":[8948],"class_list":["post-5015","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-android","category-best-practices-and-tutorials","category-couchbase-lite","category-couchbase-mobile","category-full-text-search","category-objective-c","category-n1ql-query","tag-ios","tag-swift"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.3 (Yoast SEO v27.3) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Xcode Playground for Exploring Couchbase Mobile Query API<\/title>\n<meta name=\"description\" content=\"This post is a step-by-step guide to using Xcode Playground to test and explore the Query API in Couchbase Mobile 2.0. Given the unified nature of the QueryBuilder API you should be able to easily translate the swift queries to any of the other platform languages supported in Couchbase Lite\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.couchbase.com\/blog\/xcode-playground-couchbase-mobile\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Xcode Playground for Exploring Query API in Couchbase Lite 2.0\" \/>\n<meta property=\"og:description\" content=\"This post is a step-by-step guide to using Xcode Playground to test and explore the Query API in Couchbase Mobile 2.0. Given the unified nature of the QueryBuilder API you should be able to easily translate the swift queries to any of the other platform languages supported in Couchbase Lite\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.couchbase.com\/blog\/xcode-playground-couchbase-mobile\/\" \/>\n<meta property=\"og:site_name\" content=\"The Couchbase Blog\" \/>\n<meta property=\"article:published_time\" content=\"2018-04-17T17:00:01+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-06-14T04:37:10+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2018\/04\/xcode-playground-couchbase-lite-2-0.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"728\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Priya Rajagopal, Senior Director, Product Management\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@rajagp\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Priya Rajagopal, Senior Director, Product Management\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/xcode-playground-couchbase-mobile\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/xcode-playground-couchbase-mobile\\\/\"},\"author\":{\"name\":\"Priya Rajagopal, Senior Director, Product Management\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#\\\/schema\\\/person\\\/c2da90e57717ee4970c48a87a131ac2c\"},\"headline\":\"Xcode Playground for Exploring Query API in Couchbase Lite 2.0\",\"datePublished\":\"2018-04-17T17:00:01+00:00\",\"dateModified\":\"2025-06-14T04:37:10+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/xcode-playground-couchbase-mobile\\\/\"},\"wordCount\":1277,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/xcode-playground-couchbase-mobile\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/1\\\/2018\\\/04\\\/xcode-playground-couchbase-lite-2-0.png\",\"keywords\":[\"ios\",\"swift\"],\"articleSection\":[\"Android\",\"Best Practices and Tutorials\",\"Couchbase Lite\",\"Couchbase Mobile\",\"Full-Text Search\",\"Objective-C\",\"SQL++ \\\/ N1QL Query\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/xcode-playground-couchbase-mobile\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/xcode-playground-couchbase-mobile\\\/\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/xcode-playground-couchbase-mobile\\\/\",\"name\":\"Xcode Playground for Exploring Couchbase Mobile Query API\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/xcode-playground-couchbase-mobile\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/xcode-playground-couchbase-mobile\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/1\\\/2018\\\/04\\\/xcode-playground-couchbase-lite-2-0.png\",\"datePublished\":\"2018-04-17T17:00:01+00:00\",\"dateModified\":\"2025-06-14T04:37:10+00:00\",\"description\":\"This post is a step-by-step guide to using Xcode Playground to test and explore the Query API in Couchbase Mobile 2.0. Given the unified nature of the QueryBuilder API you should be able to easily translate the swift queries to any of the other platform languages supported in Couchbase Lite\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/xcode-playground-couchbase-mobile\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/xcode-playground-couchbase-mobile\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/xcode-playground-couchbase-mobile\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/1\\\/2018\\\/04\\\/xcode-playground-couchbase-lite-2-0.png\",\"contentUrl\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/1\\\/2018\\\/04\\\/xcode-playground-couchbase-lite-2-0.png\",\"width\":1200,\"height\":728,\"caption\":\"An Xcode playground for Couchbase Lite 2.0\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/xcode-playground-couchbase-mobile\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Xcode Playground for Exploring Query API in Couchbase Lite 2.0\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/\",\"name\":\"The Couchbase Blog\",\"description\":\"Couchbase, the NoSQL Database\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#organization\",\"name\":\"The Couchbase Blog\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/04\\\/admin-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/2023\\\/04\\\/admin-logo.png\",\"width\":218,\"height\":34,\"caption\":\"The Couchbase Blog\"},\"image\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#\\\/schema\\\/person\\\/c2da90e57717ee4970c48a87a131ac2c\",\"name\":\"Priya Rajagopal, Senior Director, Product Management\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/acfb2349788955262cd069497a9e7bdb0e97c26326f2e55811e7c1174e9ef1be?s=96&d=mm&r=g4b50a54778b979d8c345b036ab138734\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/acfb2349788955262cd069497a9e7bdb0e97c26326f2e55811e7c1174e9ef1be?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/acfb2349788955262cd069497a9e7bdb0e97c26326f2e55811e7c1174e9ef1be?s=96&d=mm&r=g\",\"caption\":\"Priya Rajagopal, Senior Director, Product Management\"},\"description\":\"Priya Rajagopal is a Senior Director of Product Management at Couchbase responsible for developer platforms for the cloud and the edge. She has been professionally developing software for over 20 years in several technical and product leadership positions, with 10+ years focused on mobile technologies. As a TISPAN IPTV standards delegate, she was a key contributor to the IPTV standards specifications. She has 22 patents in the areas of networking and platform security.\",\"sameAs\":[\"https:\\\/\\\/x.com\\\/rajagp\"],\"url\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/author\\\/priya-rajagopalcouchbase-com\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Xcode Playground for Exploring Couchbase Mobile Query API","description":"This post is a step-by-step guide to using Xcode Playground to test and explore the Query API in Couchbase Mobile 2.0. Given the unified nature of the QueryBuilder API you should be able to easily translate the swift queries to any of the other platform languages supported in Couchbase Lite","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.couchbase.com\/blog\/xcode-playground-couchbase-mobile\/","og_locale":"en_US","og_type":"article","og_title":"Xcode Playground for Exploring Query API in Couchbase Lite 2.0","og_description":"This post is a step-by-step guide to using Xcode Playground to test and explore the Query API in Couchbase Mobile 2.0. Given the unified nature of the QueryBuilder API you should be able to easily translate the swift queries to any of the other platform languages supported in Couchbase Lite","og_url":"https:\/\/www.couchbase.com\/blog\/xcode-playground-couchbase-mobile\/","og_site_name":"The Couchbase Blog","article_published_time":"2018-04-17T17:00:01+00:00","article_modified_time":"2025-06-14T04:37:10+00:00","og_image":[{"width":1200,"height":728,"url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2018\/04\/xcode-playground-couchbase-lite-2-0.png","type":"image\/png"}],"author":"Priya Rajagopal, Senior Director, Product Management","twitter_card":"summary_large_image","twitter_creator":"@rajagp","twitter_misc":{"Written by":"Priya Rajagopal, Senior Director, Product Management","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.couchbase.com\/blog\/xcode-playground-couchbase-mobile\/#article","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/xcode-playground-couchbase-mobile\/"},"author":{"name":"Priya Rajagopal, Senior Director, Product Management","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/c2da90e57717ee4970c48a87a131ac2c"},"headline":"Xcode Playground for Exploring Query API in Couchbase Lite 2.0","datePublished":"2018-04-17T17:00:01+00:00","dateModified":"2025-06-14T04:37:10+00:00","mainEntityOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/xcode-playground-couchbase-mobile\/"},"wordCount":1277,"commentCount":1,"publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/xcode-playground-couchbase-mobile\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2018\/04\/xcode-playground-couchbase-lite-2-0.png","keywords":["ios","swift"],"articleSection":["Android","Best Practices and Tutorials","Couchbase Lite","Couchbase Mobile","Full-Text Search","Objective-C","SQL++ \/ N1QL Query"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.couchbase.com\/blog\/xcode-playground-couchbase-mobile\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.couchbase.com\/blog\/xcode-playground-couchbase-mobile\/","url":"https:\/\/www.couchbase.com\/blog\/xcode-playground-couchbase-mobile\/","name":"Xcode Playground for Exploring Couchbase Mobile Query API","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/xcode-playground-couchbase-mobile\/#primaryimage"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/xcode-playground-couchbase-mobile\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2018\/04\/xcode-playground-couchbase-lite-2-0.png","datePublished":"2018-04-17T17:00:01+00:00","dateModified":"2025-06-14T04:37:10+00:00","description":"This post is a step-by-step guide to using Xcode Playground to test and explore the Query API in Couchbase Mobile 2.0. Given the unified nature of the QueryBuilder API you should be able to easily translate the swift queries to any of the other platform languages supported in Couchbase Lite","breadcrumb":{"@id":"https:\/\/www.couchbase.com\/blog\/xcode-playground-couchbase-mobile\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.couchbase.com\/blog\/xcode-playground-couchbase-mobile\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.couchbase.com\/blog\/xcode-playground-couchbase-mobile\/#primaryimage","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2018\/04\/xcode-playground-couchbase-lite-2-0.png","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/1\/2018\/04\/xcode-playground-couchbase-lite-2-0.png","width":1200,"height":728,"caption":"An Xcode playground for Couchbase Lite 2.0"},{"@type":"BreadcrumbList","@id":"https:\/\/www.couchbase.com\/blog\/xcode-playground-couchbase-mobile\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.couchbase.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Xcode Playground for Exploring Query API in Couchbase Lite 2.0"}]},{"@type":"WebSite","@id":"https:\/\/www.couchbase.com\/blog\/#website","url":"https:\/\/www.couchbase.com\/blog\/","name":"The Couchbase Blog","description":"Couchbase, the NoSQL Database","publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.couchbase.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.couchbase.com\/blog\/#organization","name":"The Couchbase Blog","url":"https:\/\/www.couchbase.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/2023\/04\/admin-logo.png","width":218,"height":34,"caption":"The Couchbase Blog"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/c2da90e57717ee4970c48a87a131ac2c","name":"Priya Rajagopal, Senior Director, Product Management","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/acfb2349788955262cd069497a9e7bdb0e97c26326f2e55811e7c1174e9ef1be?s=96&d=mm&r=g4b50a54778b979d8c345b036ab138734","url":"https:\/\/secure.gravatar.com\/avatar\/acfb2349788955262cd069497a9e7bdb0e97c26326f2e55811e7c1174e9ef1be?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/acfb2349788955262cd069497a9e7bdb0e97c26326f2e55811e7c1174e9ef1be?s=96&d=mm&r=g","caption":"Priya Rajagopal, Senior Director, Product Management"},"description":"Priya Rajagopal is a Senior Director of Product Management at Couchbase responsible for developer platforms for the cloud and the edge. She has been professionally developing software for over 20 years in several technical and product leadership positions, with 10+ years focused on mobile technologies. As a TISPAN IPTV standards delegate, she was a key contributor to the IPTV standards specifications. She has 22 patents in the areas of networking and platform security.","sameAs":["https:\/\/x.com\/rajagp"],"url":"https:\/\/www.couchbase.com\/blog\/author\/priya-rajagopalcouchbase-com\/"}]}},"acf":[],"authors":[{"term_id":8948,"user_id":1423,"is_guest":0,"slug":"priya-rajagopalcouchbase-com","display_name":"Priya Rajagopal, Senior Director, Product Management","avatar_url":"https:\/\/secure.gravatar.com\/avatar\/acfb2349788955262cd069497a9e7bdb0e97c26326f2e55811e7c1174e9ef1be?s=96&d=mm&r=g","0":null,"1":"","2":"","3":"","4":"","5":"","6":"","7":"","8":""}],"_links":{"self":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts\/5015","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/users\/1423"}],"replies":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/comments?post=5015"}],"version-history":[{"count":0,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts\/5015\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/media\/11842"}],"wp:attachment":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/media?parent=5015"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/categories?post=5015"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/tags?post=5015"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/ppma_author?post=5015"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}