{"id":102,"date":"2015-12-11T15:24:18","date_gmt":"2015-12-11T15:24:18","guid":{"rendered":"http:\/\/kevingoedecke.com\/?p=102"},"modified":"2017-06-22T15:52:59","modified_gmt":"2017-06-22T15:52:59","slug":"using-loopback-ios-sdk-with-cocoapods-in-swift","status":"publish","type":"post","link":"https:\/\/kevingoedecke.com\/blog\/2015\/12\/11\/using-loopback-ios-sdk-with-cocoapods-in-swift\/","title":{"rendered":"Using LoopBack iOS SDK with Cocoapods in Swift"},"content":{"rendered":"<p>The <a href=\"http:\/\/loopback.io\/\" target=\"_blank\">LoopBack Framework<\/a> provides an easy way to create RESTful APIs and also comes with SDKs for iOS and Android, which makes it really convenient to interact with the Backend from your apps.<\/p>\n<p>The iOS SDK is available on the official website (<a href=\"https:\/\/docs.strongloop.com\/display\/public\/LB\/iOS+SDK\" target=\"_blank\">LoopBack Docs<\/a>) and on GitHub (<a href=\"https:\/\/github.com\/strongloop\/loopback-sdk-ios\" target=\"_blank\">Loopback iOS SDK<\/a>). I noticed that the version in the docs isn&#8217;t up-to-date, that&#8217;s why I decided to use the latest version of the SDK from GitHub. The developers provide a podspec file in the repo so you can easily import the Framework in your project without compiling it every time.<\/p>\n<h2>Prerequisites<\/h2>\n<ul>\n<li>An existing XCode project using Swift<\/li>\n<\/ul>\n<h2>Let&#8217;s get started<\/h2>\n<h2>Step 1: Install Cocoapods<\/h2>\n<p>You can skip this step if you already have cocoapods installed on your Mac. Otherwise simply open your terminal and run the following command:<\/p>\n<pre class=\"lang:default decode:true \">sudo gem install cocoapods<\/pre>\n<p>That&#8217;s it, you&#8217;re now ready to use cocoapods!<\/p>\n<h2>Step 2: Create a Podfile<\/h2>\n<p>Close your XCode project and in the main folder create a new file named &#8220;Podfile&#8221;.<\/p>\n<p>Insert the follwing:<\/p>\n<pre class=\"lang:default decode:true\">pod 'LoopBack', :git =&gt; 'https:\/\/github.com\/strongloop\/loopback-sdk-ios.git'\r\n\r\nuse_frameworks!<\/pre>\n<h2>Step 3: Install the Pods<\/h2>\n<p>Install the Cocoapods running the following command in your project directory:<\/p>\n<pre class=\"lang:default decode:true\">Kevins-MacBook-Pro:loopback-swift-example kevin$ pod install<\/pre>\n<p>Cocoapods will now look for the podspec file in the GitHub repo and download the\u00a0necessary framework.<\/p>\n<p>You should see the following ouput:<\/p>\n<pre class=\"lang:default decode:true\">Kevins-MacBook-Pro:loopback-swift-example kevin$ pod install\r\nUpdating local specs repositories\r\nAnalyzing dependencies\r\nPre-downloading: `LoopBack` from `https:\/\/github.com\/strongloop\/loopback-sdk-ios.git`\r\nDownloading dependencies\r\nInstalling LoopBack (1.3.0)\r\nGenerating Pods project\r\nIntegrating client project\r\n\r\n[!] Please close any current Xcode sessions and use `loopback-swift-example.xcworkspace` for this project from now on.\r\nSending stats\r\nSending stats\r\nPod installation complete! There is 1 dependency from the Podfile and 1 total pod\r\ninstalled.<\/pre>\n<h2>Step 4:\u00a0Usage<\/h2>\n<p>From now on you&#8217;ll use the<strong> xcworkspace<\/strong> file in your project directory every time you\u00a0open your app.<\/p>\n<p>Go ahead and open the xcworkspace file to fire up XCode.<\/p>\n<p>You&#8217;re now ready to use the SDK in your Swift project.<\/p>\n<p>In the swift file simply use import to include the LoopBack SDK and you&#8217;re good to go!<\/p>\n<p>Example Usage:<\/p>\n<pre class=\"lang:default decode:true  \">\/\/\r\n\/\/  WidgetViewController\r\n\/\/  loopback-swift-example\r\n\/\/\r\n\/\/  Created by Kevin Goedecke on 3\/19\/16.\r\n\/\/  Copyright \u00a9 2016 kevingoedecke. All rights reserved.\r\n\/\/\r\n\r\nimport UIKit\r\nimport LoopBack\r\n\r\nclass WidgetViewController: UIViewController {\r\n\r\n    override func viewDidLoad() {\r\n        super.viewDidLoad()\r\n        \/\/ Do any additional setup after loading the view, typically from a nib.\r\n    }\r\n\r\n    override func didReceiveMemoryWarning() {\r\n        super.didReceiveMemoryWarning()\r\n        \/\/ Dispose of any resources that can be recreated.\r\n    }\r\n\r\n\r\n}\r\n<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The LoopBack Framework provides an easy way to create RESTful APIs and also comes with SDKs for iOS and Android, which makes it really convenient to interact with the Backend from your apps. The iOS SDK is available on the official website (LoopBack Docs) and on GitHub (Loopback iOS SDK). I noticed that the version [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":106,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[15],"tags":[18,20,16,17,19],"class_list":["post-102","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-programming","tag-backend","tag-cocoapods","tag-loopback","tag-strongloop","tag-swift"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.8.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Using LoopBack iOS SDK with Cocoapods in Swift - Kevin Goedecke<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/kevingoedecke.com\/blog\/2015\/12\/11\/using-loopback-ios-sdk-with-cocoapods-in-swift\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Using LoopBack iOS SDK with Cocoapods in Swift - Kevin Goedecke\" \/>\n<meta property=\"og:description\" content=\"The LoopBack Framework provides an easy way to create RESTful APIs and also comes with SDKs for iOS and Android, which makes it really convenient to interact with the Backend from your apps. The iOS SDK is available on the official website (LoopBack Docs) and on GitHub (Loopback iOS SDK). I noticed that the version [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/kevingoedecke.com\/blog\/2015\/12\/11\/using-loopback-ios-sdk-with-cocoapods-in-swift\/\" \/>\n<meta property=\"og:site_name\" content=\"Kevin Goedecke\" \/>\n<meta property=\"article:published_time\" content=\"2015-12-11T15:24:18+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-06-22T15:52:59+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/kevingoedecke.com\/blog\/wp-content\/uploads\/2015\/12\/loopback-ios-sdk-swift@2x.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1800\" \/>\n\t<meta property=\"og:image:height\" content=\"900\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Kevin Goedecke\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Kevin Goedecke\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/kevingoedecke.com\/blog\/2015\/12\/11\/using-loopback-ios-sdk-with-cocoapods-in-swift\/\",\"url\":\"https:\/\/kevingoedecke.com\/blog\/2015\/12\/11\/using-loopback-ios-sdk-with-cocoapods-in-swift\/\",\"name\":\"Using LoopBack iOS SDK with Cocoapods in Swift - Kevin Goedecke\",\"isPartOf\":{\"@id\":\"https:\/\/kevingoedecke.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/kevingoedecke.com\/blog\/2015\/12\/11\/using-loopback-ios-sdk-with-cocoapods-in-swift\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/kevingoedecke.com\/blog\/2015\/12\/11\/using-loopback-ios-sdk-with-cocoapods-in-swift\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/kevingoedecke.com\/blog\/wp-content\/uploads\/2015\/12\/loopback-ios-sdk-swift@2x.jpg\",\"datePublished\":\"2015-12-11T15:24:18+00:00\",\"dateModified\":\"2017-06-22T15:52:59+00:00\",\"author\":{\"@id\":\"https:\/\/kevingoedecke.com\/#\/schema\/person\/4b156cd6453e1af4bab9076b0a663871\"},\"breadcrumb\":{\"@id\":\"https:\/\/kevingoedecke.com\/blog\/2015\/12\/11\/using-loopback-ios-sdk-with-cocoapods-in-swift\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/kevingoedecke.com\/blog\/2015\/12\/11\/using-loopback-ios-sdk-with-cocoapods-in-swift\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/kevingoedecke.com\/blog\/2015\/12\/11\/using-loopback-ios-sdk-with-cocoapods-in-swift\/#primaryimage\",\"url\":\"https:\/\/kevingoedecke.com\/blog\/wp-content\/uploads\/2015\/12\/loopback-ios-sdk-swift@2x.jpg\",\"contentUrl\":\"https:\/\/kevingoedecke.com\/blog\/wp-content\/uploads\/2015\/12\/loopback-ios-sdk-swift@2x.jpg\",\"width\":1800,\"height\":900},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/kevingoedecke.com\/blog\/2015\/12\/11\/using-loopback-ios-sdk-with-cocoapods-in-swift\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/kevingoedecke.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Using LoopBack iOS SDK with Cocoapods in Swift\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/kevingoedecke.com\/#website\",\"url\":\"https:\/\/kevingoedecke.com\/\",\"name\":\"Kevin Goedecke\",\"description\":\"Founder. Entrepreneur.\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/kevingoedecke.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/kevingoedecke.com\/#\/schema\/person\/4b156cd6453e1af4bab9076b0a663871\",\"name\":\"Kevin Goedecke\",\"url\":\"https:\/\/kevingoedecke.com\/blog\/author\/kgoedecke\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Using LoopBack iOS SDK with Cocoapods in Swift - Kevin Goedecke","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:\/\/kevingoedecke.com\/blog\/2015\/12\/11\/using-loopback-ios-sdk-with-cocoapods-in-swift\/","og_locale":"en_US","og_type":"article","og_title":"Using LoopBack iOS SDK with Cocoapods in Swift - Kevin Goedecke","og_description":"The LoopBack Framework provides an easy way to create RESTful APIs and also comes with SDKs for iOS and Android, which makes it really convenient to interact with the Backend from your apps. The iOS SDK is available on the official website (LoopBack Docs) and on GitHub (Loopback iOS SDK). I noticed that the version [&hellip;]","og_url":"https:\/\/kevingoedecke.com\/blog\/2015\/12\/11\/using-loopback-ios-sdk-with-cocoapods-in-swift\/","og_site_name":"Kevin Goedecke","article_published_time":"2015-12-11T15:24:18+00:00","article_modified_time":"2017-06-22T15:52:59+00:00","og_image":[{"width":1800,"height":900,"url":"https:\/\/kevingoedecke.com\/blog\/wp-content\/uploads\/2015\/12\/loopback-ios-sdk-swift@2x.jpg","type":"image\/jpeg"}],"author":"Kevin Goedecke","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Kevin Goedecke","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/kevingoedecke.com\/blog\/2015\/12\/11\/using-loopback-ios-sdk-with-cocoapods-in-swift\/","url":"https:\/\/kevingoedecke.com\/blog\/2015\/12\/11\/using-loopback-ios-sdk-with-cocoapods-in-swift\/","name":"Using LoopBack iOS SDK with Cocoapods in Swift - Kevin Goedecke","isPartOf":{"@id":"https:\/\/kevingoedecke.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/kevingoedecke.com\/blog\/2015\/12\/11\/using-loopback-ios-sdk-with-cocoapods-in-swift\/#primaryimage"},"image":{"@id":"https:\/\/kevingoedecke.com\/blog\/2015\/12\/11\/using-loopback-ios-sdk-with-cocoapods-in-swift\/#primaryimage"},"thumbnailUrl":"https:\/\/kevingoedecke.com\/blog\/wp-content\/uploads\/2015\/12\/loopback-ios-sdk-swift@2x.jpg","datePublished":"2015-12-11T15:24:18+00:00","dateModified":"2017-06-22T15:52:59+00:00","author":{"@id":"https:\/\/kevingoedecke.com\/#\/schema\/person\/4b156cd6453e1af4bab9076b0a663871"},"breadcrumb":{"@id":"https:\/\/kevingoedecke.com\/blog\/2015\/12\/11\/using-loopback-ios-sdk-with-cocoapods-in-swift\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/kevingoedecke.com\/blog\/2015\/12\/11\/using-loopback-ios-sdk-with-cocoapods-in-swift\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/kevingoedecke.com\/blog\/2015\/12\/11\/using-loopback-ios-sdk-with-cocoapods-in-swift\/#primaryimage","url":"https:\/\/kevingoedecke.com\/blog\/wp-content\/uploads\/2015\/12\/loopback-ios-sdk-swift@2x.jpg","contentUrl":"https:\/\/kevingoedecke.com\/blog\/wp-content\/uploads\/2015\/12\/loopback-ios-sdk-swift@2x.jpg","width":1800,"height":900},{"@type":"BreadcrumbList","@id":"https:\/\/kevingoedecke.com\/blog\/2015\/12\/11\/using-loopback-ios-sdk-with-cocoapods-in-swift\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/kevingoedecke.com\/"},{"@type":"ListItem","position":2,"name":"Using LoopBack iOS SDK with Cocoapods in Swift"}]},{"@type":"WebSite","@id":"https:\/\/kevingoedecke.com\/#website","url":"https:\/\/kevingoedecke.com\/","name":"Kevin Goedecke","description":"Founder. Entrepreneur.","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/kevingoedecke.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/kevingoedecke.com\/#\/schema\/person\/4b156cd6453e1af4bab9076b0a663871","name":"Kevin Goedecke","url":"https:\/\/kevingoedecke.com\/blog\/author\/kgoedecke\/"}]}},"jetpack_featured_media_url":"https:\/\/kevingoedecke.com\/blog\/wp-content\/uploads\/2015\/12\/loopback-ios-sdk-swift@2x.jpg","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/kevingoedecke.com\/blog\/wp-json\/wp\/v2\/posts\/102","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kevingoedecke.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kevingoedecke.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kevingoedecke.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kevingoedecke.com\/blog\/wp-json\/wp\/v2\/comments?post=102"}],"version-history":[{"count":17,"href":"https:\/\/kevingoedecke.com\/blog\/wp-json\/wp\/v2\/posts\/102\/revisions"}],"predecessor-version":[{"id":316,"href":"https:\/\/kevingoedecke.com\/blog\/wp-json\/wp\/v2\/posts\/102\/revisions\/316"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kevingoedecke.com\/blog\/wp-json\/wp\/v2\/media\/106"}],"wp:attachment":[{"href":"https:\/\/kevingoedecke.com\/blog\/wp-json\/wp\/v2\/media?parent=102"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kevingoedecke.com\/blog\/wp-json\/wp\/v2\/categories?post=102"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kevingoedecke.com\/blog\/wp-json\/wp\/v2\/tags?post=102"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}