<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by GitDo on Medium]]></title>
        <description><![CDATA[Stories by GitDo on Medium]]></description>
        <link>https://medium.com/@gitdoapp?source=rss-680a2f7163ea------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*qe5cECPZ7zhkX80HyXS-Bw.png</url>
            <title>Stories by GitDo on Medium</title>
            <link>https://medium.com/@gitdoapp?source=rss-680a2f7163ea------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 08:17:06 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@gitdoapp/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Framework Oriented Programming with Swift]]></title>
            <link>https://medium.com/@gitdoapp/framework-oriented-programming-with-swift-part-2-considerations-bcc9b2d76d93?source=rss-680a2f7163ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/bcc9b2d76d93</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[cocoapods]]></category>
            <dc:creator><![CDATA[GitDo]]></dc:creator>
            <pubDate>Fri, 05 Feb 2016 13:54:33 GMT</pubDate>
            <atom:updated>2016-02-05T13:56:27.899Z</atom:updated>
            <content:encoded><![CDATA[<h4>Part 2, Considerations</h4><p>In the previous <a href="http://gitdo.io/blog/2016/01/17/framework-oriented-programming-part-1">link</a>, we talked about Frameworks on iOS and did a quick introduction with the motivation for organizing our apps in Frameworks. On this post, we’ll go through a list of considerations that you should keep in mind when architecting your apps in Frameworks. We call it <em>“Framework Oriented Programming”</em> and it’s been the base architecture of GitDo.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WZcEnUGDQ97ardVHWE0fUA.jpeg" /></figure><h3>Versioning: Backward compatibility</h3><p>Version your frameworks as you version apps. <em>Why?</em> Let’s say a bug was introduced in your framework in version X.Y.(Z+1). As a result, your app starts showing off an unexpected behaviour. You can go through the commits and find which one introduced the bug, or if you are under pressure, just point your app to the previous version X.Y.Z and ship it until the bug can be fixed.<br>With every new version, prepare a detailed changelog as a reference: list the bugs the version fixed, new features introduced, breaking changes that might imply refactors in the framework consumers. Reference the commits related to these changes and be very clear with the description. You’ll thank it in the future.</p><blockquote><em>Multiple versions of the framework can be included in the same bundle ensuring backward compatibility.</em></blockquote><p>The screenshot below shows an example of a version of GitDo <em>(with funny name included)</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AReHtB6z91dfYjQ4v4ZAxQ.png" /><figcaption>Example of versioning at GitDo</figcaption></figure><h3>Dependencies</h3><p>When designing the frameworks that your app/s will depend on drawing them and with arrows illustrate the dependencies between them. In the case of having dependencies between them prefer vertical over horizontal. Look for simplicity, complexity might lead to circular dependencies and more than one headache in the future.</p><blockquote><em>On GitDo we’ve got defined principles for the architecture. One of these principles is called“One Step Dependency” which says that each framework should depend only on frameworks 1 level below itself and no more levels. Frameworks public interfaces should be wrapped up to be consumed by the level just on top of you. That way if you remove one of the “lego” blocks, only the level over this one would be affected.</em></blockquote><p>Think of your Frameworks as a stack where you have a Core Framework and you build the others on top of each other. If you need inspiration, Apple is a good example. Dive into their frameworks and how they are structured and connected to each other: <em>UIKit</em>, <em>AVFoundation</em>,<em>Foundation</em>, <em>MapKit</em>…</p><p>An example of stack of Frameworks for your apps could be <em>(sorry if I am not good enough using Sketch)</em> the one shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zyr8J1NPYg4Y2k9JosS5uw.png" /><figcaption>Current Frameworks Architecture at GitDo</figcaption></figure><h3>Single Responsibility Principle</h3><p>Your Frameworks must have a <strong>purpose</strong>. Answer this question before starting coding the framework:</p><blockquote><em>What problem is the Framework trying to solve? Do I really need it?</em></blockquote><p>If we analyse existing Frameworks and try to answer that same question:</p><ul><li><strong>CoreData</strong>: Defines a set of components for interacting with local databases. <em>(Reusable in multiple platforms)</em></li><li><strong>UIKit</strong>: Provides a set of classes that represent interface elements like buttons, bars, labels, …. Reusable on iOS, OS X, watchOS, and tvOS. <em>(Reusable in multiple platforms)</em></li><li><strong>RxSwift</strong>: Provides components to work with Reactive Programming concepts quickly.</li></ul><p>If your Framework has multiple purposes, you might need more than one framework instead. If you can not answer the question, you might not need a Framework.</p><blockquote><em>Do not reinvent the wheel. If there is another framework for the same purpose and your project is aligned with its principle, go with it.</em></blockquote><h3>Visibility</h3><p>With Swift we have keywords, <em>public</em>, <em>private</em>, <em>internal</em> for specifying the visibility of our classes, structs, properties, functions, … When coding an app we don’t usually pay attention to the visibility since by default it’s <em>internal</em> and we don’t have to expose anything out of the app scope. <strong>But what about Frameworks?</strong> In this case, you have to make <em>public</em> all the components that the consumer of your Framework has access to <em>(and it’ll likely be a few of all the components)</em>. As by default the visibility if internal our suggestion is that you first, code the framework, and then, start using it and making <em>public</em> these methods that have to be accessed.</p><blockquote><em>Although the default visibility is </em>internal<em>, we prefer being more explicit and specifying the visibility everywhere, but it is not actually needed.</em></blockquote><h3>Document</h3><p>Once you have the Framework ready to be used, your teammates will link the framework with the main app target and start using it. In order to make it easy for them make sure that your Framework is documented:</p><ul><li>Add a brief explanation about how to integrate the framework with any existing project <em>(in case of having compatibility with any 3rd dependency manager, explain how to use it to link the app with your framework)</em>.</li><li>Introduce your Framework components, its purpose and how to use them.</li><li>Add documentation to the public entities <em>(methods, attributes, classes, …)</em>.</li></ul><p>You can use a tool like <a href="https://github.com/Realm/jazzy">Jazzy</a> from Realm that generates a delightful HTML website with the documentation using Apple’s style. You can even use <a href="https://pages.github.com/">GitHub Pages</a> in order to upload your documentation website and make it available for the rest. If the Framework project is integrated with any CI platform you can run an script for deploying the documentation to that GitHub repository.</p><blockquote><em>Even though you can generate automatic documentation from your code comments, having a manually written reference explaining how to use your frameworks is very handy for developers in your team depending on your frameworks. Whenever they have questions or concerns the can just use that reference.</em></blockquote><h3>Guidelines</h3><p>Define the guidelines for your Framework project, from the principles of the Framework to the code style. Think that a teammate that don’t usually develop the Framework, might need to implement and propose something for the Framework. If you didn’t have these guidelines defines the developer would start adding code to the frameworks without mattering the code style, the architecture you decided for these frameworks, or why not, the design principles your frameworks stick to.</p><p>Making it with GitHub is relatively easy, create a file CONTRIBUTING.md. Every time the developers propose changes, they will be alerted about these existing guidelines and will suggest reading them before going on with the proposal.</p><blockquote><em>Undocumented code components are like black boxes with public “elements” that can be consumer. If it works, none is going to jump into implementation details. But if something went bad developers would go into that black box and start adding workaround for the problems found or the features required. Enforce good practices with a guideline and don’t allow them to make this black box even darker.</em></blockquote><h3>Responsible team</h3><p>If you have enough people in the team assign people to frameworks are responsible people.<strong>Why?</strong></p><ul><li>They ensure the quality of the code. When you don’t have people responsible for that piece of code in your project, everyone can go into the framework and change it according to their needs <em>(and most of the times without following the defined guidelines).</em></li><li>If something goes wrong, they know about changes and versions in the framework and they can quickly revert it.</li><li>Instead of having people jumping between UI, Data, Business logic you have people focused on only one of these pieces. If you have people expert on UI or that loves designing with Interface Builder, why not keeping that person in the UI framework?</li></ul><blockquote><em>It depends on how many people you are in your team. If you have enough people, it’s definitively something worth it.</em></blockquote><h3>Loading time using Dynamic Frameworks</h3><p>We had a bad experience in loading time when using a lot of Frameworks. Since Frameworks are dynamically loaded in runtime it takes an extra time to load all your Framework. The firsts versions of GitDo which had around 8–9 Frameworks took around 6–7 to load fully. <strong>What was the solution?</strong> Identify these Frameworks that weren’t simultaneously dependency of multiple Framework and remove them from the embedded section. After that were able to decrease the load time to 2–3 seconds. When I was writing this article, I did research to understand why this is happening. I got to this <a href="https://github.com/artsy/eigen/issues/586">thread</a> on the <em>Artsy Eigen</em> repository trying to find a solution to this problem.</p><h3>Access to Bundle Resources</h3><p>As I mentioned earlier, Frameworks support assets in its own bundle. Instead of accessing NSBundle.mainBundle() you have to get the bundle using any class from your Framework:</p><p><strong>NSBundle</strong>(forClass: <strong>MyFrameworkClass.classForCoder</strong>())</p><blockquote><em>Accessing resources with static libraries and CocoaPods led to some missing resources when Frameworks support was introduced in CocoaPods since developers accessed resources using NSBundle.mainBundle()</em></blockquote><h3>Dependency manager</h3><p>There’s recently a big significant about dependency managers, <a href="https://cocoapods.org/">CocoaPods</a> had been the reference from years, but <a href="https://github.com/carthage/carthage">Carthage</a> came out a few months ago as an alternative to CocoaPods offering a decentralized approach. <strong>You can create your Frameworks architecture without any dependency manager</strong>. The steps to get it done are:</p><ol><li>Creating a workspace with all the projects.</li><li>Connecting the project dependencies and importing the resulting frameworks.</li><li>Compiling. Voila!</li></ol><p>However, you might need some external dependencies <em>(which we recommend you to minimize)</em>. But if you need them, your dependencies tree becomes more complex. You can resolve them manually and use tools like git submodules to clone them locally or automatize it <strong>CocoaPods</strong> or <strong>Carthage</strong>.</p><h4>CocoaPods or Carthage?</h4><p>Our first version of the architecture used Carthage. In case you don’t have experience with Carthage what it does is resolving the dependency tree using GitHub, flatting these frameworks in a single project and, if you specify it, also get the compiled version of these Frameworks. The step of adding these frameworks to the project is up to you, and that’s the different key point compared with CocoaPods.</p><blockquote><em>Carthage doesn’t modify anything from your </em>.xcodeproj<em>, or </em>.xcworkspace.</blockquote><p>After months of use we found a few problems that made our development slower:</p><ol><li>We were initially using the compiled frameworks. When a Framework is compiled with a version of Xcode 7.XX and you try to use them from 7.(XX)+1 then the Frameworks are not valid and has to be recompiled. It has to recompile all the frameworks when the new version of Xcode is released <em>(cross your fingers because if the source project doesn’t have the correct project configuration the compilation might fail)</em>.</li><li>As Carthage doesn’t create the configuration of the Framework to be compile if the source developer didn’t setup everything properly you might have troubles compiling your dependencies. Attempting to compile a project for a platform and the developer forgot to add that platform as a supported one. Or trying to compile the project and there’s a flag somewhere that makes it fail when Carthage tries to compile it. If your list of Carthage dependencies is large, with new updates it supposes a big headache, especially when your workmates try to setup everything.</li><li><strong>Carthage + Debugging = Xcode Crashes</strong>. We couldn’t debug the project. Every time we tried to add a breakpoint in the project the application crashed and we ended up debugging using logs. We thought it was related to Xcode or a lot of Reactive code but after migrating with CocoaPods, the debugging is much nicer now.</li></ol><p>We ended up migrating to CocoaPods. Each framework has its own .podspec file with the configuration of that Framework and we resolve these local dependencies using CocoaPods<em>(which also bring the external dependencies)</em>. Working with local dependencies and CocoaPods is very straightforward since it creates a group in the project where you can modify your files from. After this migration to CocoaPods, problems setting up the project decreased.</p><blockquote><em>We’re not saying Carthage is bad compared with CocoaPods but in our case we found some troubles with the setup. Carthage might not be the perfect one for our setup or we didn’t setup properly the dependencies after following all the steps on the repository, these are the problems that came up.</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/296/1*Osie3bAdh4faXCBvdocweA.png" /></figure><h3>Creating our Framework</h3><p>We were going to write the steps to create a Framework <em>Carthage/CocoaPods</em> compatible but <a href="http://gitdo.io/blog/2016/01/20/framework-oriented-programming-part-2">Thoughtbot</a> recently did it on <a href="https://robots.thoughtbot.com/creating-your-first-ios-framework">this post</a>. They explain all the necessary steps to create a project for your framework, make it compatible with the popular dependency managers and finally add a testing target to test your Frameworks.</p><h4><a href="https://robots.thoughtbot.com/creating-your-first-ios-framework">Link to the post</a></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*zBxIpzf1y5bhnt6e.png" /><figcaption>Thoughtbot post explaining how to create an iOS Framework.</figcaption></figure><h4><a href="http://gitdo.io/blog/2016/01/20/framework-oriented-programming-part-2">Post originally published on gitdo.io/blog</a></h4><h3>References</h3><ul><li>Apple Dynamic Library Programming — <a href="https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/DynamicLibraries/000-Introduction/Introduction.html">Link</a></li><li>Building modern frameworks — <a href="https://developer.apple.com/videos/play/wwdc2014-416/">Link</a></li><li>Frameworks vs Library (Cocoa, iOS) — <a href="http://www.knowstack.com/framework-vs-library-cocoa-ios/">Link</a></li><li>Library Oriented Programming — <a href="https://realm.io/news/justin-spahr-summers-library-oriented-programming/">Link</a></li><li>CocoaPods 0.36 — Framework and Swift Support — <a href="https://blog.cocoapods.org/CocoaPods-0.36/">Link</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bcc9b2d76d93" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Framework Oriented Programming with Swift]]></title>
            <link>https://medium.com/@gitdoapp/framework-oriented-programming-with-swift-ecb83261983e?source=rss-680a2f7163ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/ecb83261983e</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[framework]]></category>
            <category><![CDATA[swift]]></category>
            <dc:creator><![CDATA[GitDo]]></dc:creator>
            <pubDate>Mon, 18 Jan 2016 22:28:05 GMT</pubDate>
            <atom:updated>2016-01-18T22:28:05.808Z</atom:updated>
            <content:encoded><![CDATA[<h4>Part 1, Motivation</h4><p>Prior to iOS 8 and the launch of Swift, Objective-C libraries were integrated with your project as <strong>static frameworks</strong> <em>(we could also add manually the files to our app target)</em>. These static frameworks included the symbolic links to the lib and the headers. The assets had to be distributed using .bundles. Dependency managers like <a href="https://cocoapods.org/">CocoaPods</a> read the .podspec file and created these static frameworks and bundles that were linked with our projects.</p><p>With the introduction of Swift, Xcode did not support creating static frameworks with <em>Swift code</em>. What was the solution proposed by Apple?<strong>Dynamic Frameworks</strong>. Dynamic Frameworks have long been a vital part of developing for MacOS, but Xcode did not support building them for iOS <em>(Xcode refers to them as embedded frameworks)</em></p><blockquote><em>Dynamic libraries allow an application to load code into its address space when it’s actually needed. This can be either at launch time or at runtime. Dynamic libraries are not part of the application executable file. When an application is launched, the application’s code is first loaded into the address space of the process. The dynamic loader — usually dyld on Apple’s platforms — takes control of the process and loads the dependent libraries. This involves resolving their location on the file system based on their install name, and then resolving the undefined external symbols needed by the application. The dynamic loader will also load additional libraries at runtime, as they are requested.</em></blockquote><h3>Why create Frameworks?</h3><p>The main reason that motivates the creation of Frameworks when coding our apps is the <strong>reusability</strong>. Not only the libraries you find out there are reusable components, but the code inside your apps. If you write a bunch of code for the interaction with an API, that one might be reusable by another app that points to the same API. If you develop your own wrapper for CoreData, you might need that wrapper in the future. As an example, Apple tends to develop core frameworks for their main apps, HealthKit for their Health app, or MapKit for their Maps one.</p><blockquote><em>If the code appears more than once, it probably belongs to a framework.</em></blockquote><p>A very important motivation appeared when Apple released the <em>Apple Watch</em>, because we needed to reuse part of our code bases for it. I remember it was not easy when I tried, since the core components where very tied to each other. The design of the core architecture was not good enough and it resulted into a big headache. A few years ago we only had iPhone to develop for, iPad later, then Watch, and recently the Apple TV. If you start with a project that<strong>might be ported to multiple platforms</strong>, coding the core business logic in frameworks should be a must do.</p><p>Implementing a framework we are actually creating an API that is going to be consumed from a another point. When we code everything in the same bundle we do not care that much about the interfaces, but the logic. When our frameworks are going to be <em>consumed</em> that is a very important point to be taken into account.</p><blockquote><em>As developers, designing frameworks make us better developers and pay attention to aspects we didn’t pay attention before like visibility, documentation, testing, patterns, error handling, logging, …</em></blockquote><p>We can find another big advantage in <strong>testing</strong>. <em>Have you suffered vast code bases with more than hundreds of tests taking 5 minutes to be executed? I have</em>. When you create frameworks you are also bundling tests in multiple testing targets. If anything changed from your framework, you don’t need to run the tests suite of your whole app but only the tests of your framework. It incredibly increases the speed of development. You can have people in your team focused on maintaining core frameworks, ensuring their logic is robust through unit tests, and providing you with the set of components your apps need for working.</p><p><em>In the next post we will analyze the important points to keep in mind before going ahead with your Framework: architecture ideas, dependency manager depending on your setup, versioning… Remember that you can subscribe to our mailing list and we’ll send new posts directly to your email when they get published.</em></p><h4>If you are interested in GitDo and our publications, you can subscribe to our mailing list to get automatic updates. Join it <a href="http://eepurl.com/bNhDCH">here</a></h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ecb83261983e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GitDo: Designing the app infrastructure]]></title>
            <link>https://medium.com/@gitdoapp/gitdo-designing-the-app-infrastructure-3b7710c0fd81?source=rss-680a2f7163ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/3b7710c0fd81</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[reactive-programming]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[GitDo]]></dc:creator>
            <pubDate>Wed, 30 Dec 2015 18:01:49 GMT</pubDate>
            <atom:updated>2016-03-08T08:37:56.032Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WR84lFtQcb-BHRfPtaJ8NQ.jpeg" /><figcaption>Photo by Buzac Marius</figcaption></figure><p>Back in May when we decided to start this new project we had a lot of doubts moving around around:</p><blockquote><em>Should we go ahead with Swift? Should we give a try to Carthage? CoreData or Realm? What architecture should we stick to?</em></blockquote><p>Since our first commits we have changed lot of things and we are still iterating over these questions. We have suffered the pain of Swift versions, the updates of <a href="https://github.com/ReactiveCocoa/ReactiveCocoa">ReactiveCocoa</a> getting ready for Swift, or even migrations in our data models. In this post I will cover that decisions that we initially took for building GitDo, what they resulted into, and the outcomes of all these technical decisions that <strong>might be useful for iOS developers starting new projects</strong>.</p><h3>Choosing the language: Swift</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/200/0*xtNhe3wy-3tROwi6.png" /></figure><p>Before starting the project we had done a few experiments with <a href="http://swift.org/">Swift</a> and it was promising for us. It brought fresh syntax to the ecosystem and it was iterating quite fast. <em>Something positive</em> from deciding Swift as a language for the project is that the language aims to write more secure code, and helps to build a more stable. One key component here is the security with types that are detected at compilation time. No more unknown id objects that we casted to access its properties. Since the first private versions we have been using, we haven’t suffered any critical crash, but failures due to a bad use of the language and crashes in Xcode, <em>debugging was such a pain!</em>. <strong>As a negative point</strong>I could say that choosing Swift from a so early state requires an extra effort from developers making sure the code is up to date to the last versions if you want to use the last Xcode version. But it was almost one year ago, if you’re starting a new project and you have to choose the language <strong>Swift is your best option</strong>, with the last 2.x version, the language is getting consolidated. With Swift getting Open Source we will see new improvements coming but in my opinion not a lot of breaking changes for your code base <em>(let’s see)</em>.</p><h3>API interaction</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/200/0*2GwKZDWqM3bZjhOo.png" /></figure><p><a href="http://gitdo.io/">GitDo</a> interacts with <a href="https://github.com/">GitHub</a> and our own backend persisting some basic user information. Existing frameworks were written in Objective-C and offered a full interaction with the GitHub API. We just needed only a subset of these requests and also new ones for interacting with our own backend. We decided in this case to go ahead with our own API repository and internal requests builders. We use <a href="https://github.com/alamofire/alamofire">Alamofire</a>, especially its components for request and response serializing. NSURLSession has a nice API but does not offer any component to serialize request data into NSURLRequests, wee took that one from Alamofire. We implemented Routers that are responsible for creating requests that get executed. Implementing our custom solution was a great idea since it gives us a lot of flexibility and we can modify that layer easily without having to fork 3rd party repositories but we have found some problems with the design that we are solving in future iterations:</p><ul><li><strong>Don’t map API responses into database models</strong>: We map the responses into Realm models that are created to be inserted into the database. Thinking that your API responses map 1-to-1 with your local database models was a very bad idea. APIs are designed to be flexible, thus, they offer a very different design from what you will end up needing in your app. Implement API models that can be Swift structs with explicit names ApiIssue, ApiRepository if you don’t want to have naming conflicts with other models.</li><li><strong>Models should not be responsible of mapping themselves</strong>: Single Responsibility Principle is called, isn’t it? Models contain a set of attributes and methods specific to the model itself. They should include a constructor that take the initial attributes values and set them but… they should not know how to get initialized from another data model. <em>Models are the result of adapting API responses. Multiple response formats can be mapped into the same model, thus, multiple mappers are required for these responses</em>. As soon as you start adding mappers to the model your code will smell like you’re adding responsibilities that shouldn’t belong to your model. <strong>Use adapters instead!</strong></li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2ff097b9d3acaeeb8afff26b7bfbbe4c/href">https://medium.com/media/2ff097b9d3acaeeb8afff26b7bfbbe4c/href</a></iframe><p>A lot of JSON parsing libraries <em>(yes… there’re a lot out there)</em>, aim to conform pre-defined protocols and using protocol extensions you are automatically getting parsing methods that you can use. This is great if you are 100% your API responses map 1-to-1 with your models, but are you?</p><blockquote><em>We use </em><a href="https://github.com/SwiftyJSON/SwiftyJSON"><em>SwiftyJSON</em></a><em> as a JSON parsing library, it was one of the first libraries coming out and its approach is very simple and enough for our requirements. It’s not a protocol-extension based solution like for example Genome, so it’ll allow us to use them for our mappers.</em></blockquote><ul><li><strong>Top level instances</strong>: We created top level ApiRepository that behaves as singleton instance. These instances contain information about the base URL and they know how to perform given requests returning the result as a Reactive observable object. Using global instances leads to stateful code passing and referencing these instances instance across our code base. Do we really need it? What do we need to get data from the API?</li><li>Resource URL.</li><li>REST method.</li><li>Parameters and its serializer.</li><li>User authentication token.</li><li>Response serializer <em>(optional)</em>.</li></ul><p>All of them can be wrapped in something called NSURLSession that can be passed to the NSURLSession, that’s all! If we want to simplify the creation of these requests we can have requests factories that build these request for you and then you can use them with Alamofire, NSURLSession or any other HTTP framework you want to.</p><blockquote><em>The idea of having ApiManager or ApiClient in our apps became very popular in the community inspired by the idea of having singleton instances that persist client configuration and session state. When we did only have NSURLConnection with a Delegate pattern having these manager instances made sense, but nowadays? I don’t think so. When you keep the session in your ApiClient and in your Keychain you don’t have a single source of true, both persist what should be the “same state”, what if the user logouts, are you sure the session is cleaned from everywhere? </em><strong><em>Try to have single sources of true in your code and don’t duplicate states</em></strong><em>.</em></blockquote><p>I recently implemented a framework, <a href="https://github.com/swiftreactive/httpcommander">HTTPCommander</a> that offers a Reactive Command pattern for HTTP requests, aiming for this repository based solution for creating request. We will likely start moving our requests to commands.</p><h3>Reusable business logic: Frameworks</h3><p>We started coding GitDo as a tool for your pocket, an iOS app, but with the idea of porting it to OSX and other platforms. It implies bundling your business, non-ui dependent logic into its own bundle. We created a project, GitDoCore with targets to build a framework for iOS and OSX. Local dependencies are available in both, iOS and OSX and we selected external dependencies that were compatible with both platforms. Here’s the list:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/61ed1c6863b732afe4c7a2f995fb3043/href">https://medium.com/media/61ed1c6863b732afe4c7a2f995fb3043/href</a></iframe><p>These dependencies are resolved using with <a href="https://github.com/carthage/carthage">Carthage</a> and in case of our local frameworks we have them as git submodules and added to the project as<em>Target Dependencies</em> which allows us debugging the code in these frameworks with the main app.</p><p><strong>Frameworks is a great idea</strong> not only for the fact that you can easily reuse the code but also helps you to create decoupled and reusable code from any app, you focus in the business logic itself. If you are starting a new project that will scale in the future horizontal and vertically you should consider organizing your app in multiple frameworks. Try to design your how your map of frameworks would be and simplify the dependencies as much as possible, try vertical over horizontal design and use versioning. CocoaPods local pods can be a solution but if your frameworks have external dependencies, but if they don’t Xcode offers everything you need:</p><ol><li>Create a project that compiles a target framework for iOS or OSX.</li><li>Add the project to your app workspace.</li><li>Add the target as a <em>Target dependency</em> of your app target.</li><li>Link your app target against that framework. Voila, your AppKit, AppFoundation, or AppUIKit!</li></ol><blockquote><em>When Apple launched the Apple Watch and aimed developers to extract the common business logic into a framework and link them in both, your App and Watch Extensions. Did you notice how difficult it was getting it out? When you code everything in a single bundle it is relatively easy to couple everything, the context aims for that.</em></blockquote><p>Check out our <a href="https://github.com/gitdoapp">Github profile</a>, we also open source some libraries we implemented for our app like our delightful <a href="https://github.com/gitdoapp/gitdokanban">Kanban</a> that <a href="http://twitter.com/saky">@isaacroldan</a> implemented on Swift.</p><h3>Dependency manager: Carthage &amp; CocoaPods</h3><blockquote><em>Should I use CocoaPods or Carthage?</em></blockquote><p>That question has become a very common in the community. Each of them have their own pros and cons that made them suitable for some scenarios and not for another. We use both in GitDo and we are satisfied with the integration.</p><ul><li><a href="https://github.com/carthage/carthage"><strong>Carthage</strong></a>: As you might know the core idea behind Carthage is not being a centralized dependency manager but use Github and plain the dependencies tree into a flat list of frameworks that you add to the project on your own. <em>We resolve and build the dependencies for you, you add them to your project</em>. We use it for GitDoCore and GitDoKanban dependencies <em>(listed above)</em> and so far we haven’t had any major project. Some months ago it was a bit complicated to find libraries giving support to Carthage but nowadays most of them do. Moreover they’ve lately improved the build script using GitHub releases to make the build process much faster.</li></ul><blockquote><em>The only big downside we have found in Carthage is that when Apple releases a new Xcode version that implies changes in the project structure it is up to the developers to update their libraries to </em><strong><em>make them compatible</em></strong><em> with these changes. That might take a lot of time depending on the library.</em></blockquote><ul><li><a href="https://cocoapods.org/"><strong>CocoaPods</strong></a>: On the other side, the most used dependency manager. In this case it’s based on a centralized solution where projects include a .podspecfile with the information about how the libraries have to be linked with your project. The big advantage of using CocoaPods is that almost all the libraries offer support to CocoaPods, the community is more opened, and in comparison with Carthage, changes in the projects structure can be solved with a CocoaPods update.</li></ul><p>We use CocoaPods for the main project mostly iOS dependencies.</p><h3>Architecture: VIPER</h3><p>Regarding the architecture of the app we decided to use VIPER. If you have not heard about VIPER before <a href="https://www.objc.io/issues/13-architecture/viper/">here</a> you have a very interesting post from <a href="https://www.objc.io/">objc.io</a>. In our case instead of having all the components within the app bundle we moved the interactors and repositories to our GitDoCore. All the presentation layer wich is platform dependent is in the main app target.</p><p>We created interactors for every feature of the app, IssueInteractor, AccountInteractor, UpgradeInteractor, their structure was quite similar, all of them depended on the API and Database repositories and exposed its operations as Observables. Their responsibility is then:</p><ul><li>Keeping the reference to the repositories that are injected when the interactor is initialized.</li><li>Generating Observables that encapsulate the operations.</li><li>They create kind of namespaces for the business logic.</li></ul><h3>Local persistence: Realm</h3><p>The first version of GitDo was designed to use Realm, we liked Realm as a persistence solution, its API was very straightforward and avoided a lot of boilerplate working with data. We implemented our models inspired in the GitHub API models but after some months of development we came up with an idea, <strong>why not having a non-relational storage with collections?</strong> Our relationships were very simple and we could perform multiple fetches against these collections to get the data we needed to be presented.</p><p>We got rid of Realm and started moving the core towards that solution. <em>Guess what happened?</em> The more we implemented the more we figured out that we needed the ease of fetching relationships in plain models, accessing relationships as attributes instead of adding that extra layer building queries on these multiples collections. Our ideal idea of non-relational database became inconsistent for us and we decided to <strong>go back to Realm again</strong>.</p><p>We rebuilt our core with Realm in the base, taking advantage of it to add Unit Tests to GitDoCore. We have been using Realm until now and we’re very happy with it. As I mentioned earlier we did something wrong mapping our API responses directly into database models. We used Realm models in this case but that couples your entire data layer to that persistence layer. My <strong>suggestion</strong> regarding this question is that you have three plain models, ApiModel, DatabaseModel, Entity :</p><p><strong>Realm or CoreData?</strong></p><p>If you master CoreData, and found your perfect stack and wrapper that you are happy working with, keep with it. Realm is supposed to be faster than CoreData and the API is more friendly but, <em>do we really need that extra of performance in our apps?</em>. The only thing we miss from Realm is having a NSFetchedResultsController or better Notifications to have presentation layer that automatically updates its content according to the changes that committed in the database. <strong>Independence between database operations and fetching</strong>.</p><h3>Reactive Interfaces</h3><blockquote><em>No more completion blocks/closures</em></blockquote><p>And last but not least our decision to go with Reactive. We had heard about Reactive Programming and we were curious about how it would be in our app, so, without thinking twice, we started building the data layer with Reactive interfaces:</p><ul><li><strong>HTTP Requests</strong> That are Observables, they get executed when there is a subscriber interested. It allows us to build pipelines of data that flows from the API to the database mapping, combining, and subscribing to events.</li><li><strong>Database Fetches</strong>: Our database wrapper is pure reactive, fetch your models subscribing to an Observable, fetch them in background and map them into a thread-safe struct that you can use in the main thread to update the UI, execute a high load operation in background and subscribe to its completion or error to revert your changes in the UI.</li></ul><p>We started falling in love, there are some downsides in Reactive programming but the magic of designing streams and combining them is worth of try. We quickly fell in love and <strong>move RP to the presentation layer. How?</strong> ReactiveCocoa offers custom properties whose changes you can subscribe to. Internally they use didSet statement of Swift properties to notify the changes. If you combine that with the MVVM you can synchronize the view with the model changes.</p><blockquote><em>RxSwift also Observable attributes and some other wrappers around Foundation patterns and UIKit components.</em></blockquote><p><strong>Reactive Programming design examples are presented in the book </strong><a href="https://leanpub.com/reactiveprogrammingswift"><strong>Reactive Programming in your Swift Apps</strong></a><strong> that I am writing. The book introduces RP core ideas, the base components of RxSwift and ReactiveCocoa and get you through a real example implementing a GitHub client app.</strong></p><h4>If you are interested in GitDo and our publications, you can subscribe to our mailing list to get automatic updates. Join it <a href="http://eepurl.com/bNhDCH">here</a></h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3b7710c0fd81" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Designing a new experience with Github issues]]></title>
            <link>https://medium.com/@gitdoapp/designing-a-new-experience-with-github-issues-b17550529138?source=rss-680a2f7163ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/b17550529138</guid>
            <category><![CDATA[github]]></category>
            <category><![CDATA[trello]]></category>
            <category><![CDATA[startup]]></category>
            <dc:creator><![CDATA[GitDo]]></dc:creator>
            <pubDate>Thu, 17 Dec 2015 10:22:29 GMT</pubDate>
            <atom:updated>2015-12-17T10:23:53.662Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nAy5DJX3bvsc8Yegxig8qg.jpeg" /><figcaption>The Museum of Modern Art, New York, United States By Todd Quackenbush</figcaption></figure><p>Almost 9 months ago we started with this adventure called GitDo. Started with a developer friend, thinking about any app project that we could develop together and have our first real experience releasing a product with the idea of turning it into a product in the future. As we were both developers and we had been working for a tasks management platform by that time, <a href="https://redbooth.com/">Redbooth</a> we suffered the big problem of having to deal with multiple platforms for managing your repositories, webhooks not synchronizing properly, issues closed on <a href="https://github.com/">Github</a> that were not closed in your management platform, let’s say <a href="https://trello.com/">Trello</a>, <a href="https://todoist.com/">Todoist</a> or any other that you can use thanks to these bridging tools out of there, the most known, <a href="https://ifttt.com/">IFTTT</a>.</p><blockquote><em>Can’t we use only Github issues? The current format is very simple which explains why developers choose other solutions instead but what about if we come up with a solution on top of issues adding extra performance-boosting features?</em></blockquote><p><em>“Yes!, it sounds a great idea”</em> we both thought and then we started working on GitDo.</p><h3>Native experience</h3><p>Whenever you start something the first thing you should do is look around if there are other companies or products doing something similar. By that time there were multiple products trying offer a solution on top of Github issues. Listing some, <a href="https://zenhub.io/">Zenhub.io</a>, <a href="https://waffle.io/">Waffle.io</a> and <a href="https://huboard.com/">Huboard</a>. <a href="http://stackshare.io/stackups/waffle-io-vs-huboard-vs-zenhub">Here</a> you’ll find a comparative table of these products. All of them had something in common, they were web based solutions, <strong>Zenhub</strong> for example offered a Chrome App that modified the Github layout to add its features modifying the DOM of Github. If you have experience with that the first thing that might have come to your mind is, what if Github changes the layout? The solution breaks down until the team can fix it <em>(and this actually happened recently with a light layout modification Github recently did)</em>. Others directly offer their website and using your Github account they get issues from the API and list them with their own format. <strong>Waffle.io</strong> is based on that but the layout is very classic, old-styled and far from the visual experience that Github offers to developers <em>(I’ve to say that Zenhub did a great job here because their designs are perfectly aligned with Github as a product)</em>.</p><p>We decided to follow a different approach. We were going to develop instead a native experience, first for Apple platforms, iPhone/iPad/OSX and then if everything goes fine and we find support Android as well. We have followed a <em>frameworks based</em> approach developing the iOS version, we’ve suffered constant Swift updates, but we came up with a reusable framework that can also be used for OSX so the development of the product for that platform will be layout development.</p><blockquote><em>We’ll write a post in a few weeks about how to implement a </em>frameworks-based <em>application and the architecture we followed for our app.</em></blockquote><p>Thanks to choosing native development GitDo can benefit from native features. Listing some of them:</p><ul><li><strong>iOS Push Notifications</strong></li><li><strong>Quick Actions from Apple Watch</strong>: Replying to a comment in an issue, closing an issue, taking a look at your assigned issues.</li><li><strong>Share Extension: </strong>Imagine receiving an email and turning it into an issue. That email can be from a user complaining about a problem in your last awesome framework.</li><li><strong>3D Touch:</strong> Open your favorite projects directly using the new iPhone 6S gesture on the app icon.</li><li><strong>Spotlight:</strong> Search your projects, issues, comments directly from the search center on iOS.</li></ul><p>The list is large, and it’ll be increasing, we’ll be giving more support to these features and new features coming from Apple in new iOS updates.</p><blockquote><em>We’ll keep two of our project values, </em><strong><em>simplicity</em></strong><em> and </em><strong><em>performance focused</em></strong><em>. Every new feature will be as simple as possible to aim quick interactions with issues but at the same time, the impact on the performance will be very high.</em></blockquote><h3>Kanban</h3><p>When we first thought how the new format for issues could be we came up with a format products like <a href="https://www.trello.com/">Trello</a> are using. Instead of showing the issues in a list with filters we introduced the Kanban concept but with Github issues. We’re still not sure how developers will use the Kanban but lot of companies use it for reflecting the status of a task since it’s added to the backlog until the task is finally completed: <em>SPRINT BACKLOG, WORKING ON, REVIEW, DONE</em>. We’re using GitDo internally to manage our sprints and we’re very proud of the result. Instead of checking the labels to now if a task is in progress or not, we just take a look at the list this issue belongs to, <em>that’s all!</em></p><h3>Mobile</h3><p>We started designing the experience for mobile first. It might sound weird especially thinking that most developers have to work with computers. It would make more sense having a desktop app, wouldn’t it? We’ve to validate some ideas of use of the product, and understand developers needs with our first version and then pivot the product to find the best way to help developers with their productivity. We know about our experience using repositories, about how our work mates do, but what about developers out of there? There are a lot of developers profiles:</p><ul><li><strong>Open Source Developer</strong>: The kind of developers that has multiple frameworks open sourced in its <a href="https://github.com/">Github</a> profile and likes being constantly active with the activity on these repositories. That’s the perfect developer for quick interaction with issues, for example, using push notifications <em>(e.g. a push notification when a developer reports a bug in your library)</em>.</li><li><strong>Company Based Developer</strong>: This developer loves using Github at the workplace but afterward it doesn’t want to know anything else about Github activity. In that case, it would make more sense having a desktop productivity solution. GitDo for Desktop would be perfect for these kinds of developers. And if they’re part of a company support companies in your product business model it’s something to consider for a desktop solution of GitDo.</li></ul><blockquote><em>We do not discard iterating on different platforms and formats. iPad/OSX/Android are on the table. If you’re interested in taking part on the project and contribute to the idea, drop us a line, </em><a href="/service/mailto://team@gitdo.io"><em>team@gitdo.io</em></a><em>, we might be interested!</em></blockquote><h3>What’s coming?</h3><ul><li><strong>Release first version of GitDo 1.0:</strong> Track how developers use the app, get feedback from them, iterate and improve the user experience.</li><li><strong>iPad:</strong> We’ll adapt the layout to be iPad compatible, the experience using the Kanban will improve on this new screen format.</li><li><strong>OSX:</strong> We strongly believe in the opportunities of GitDo as a desktop app for companies. Once we define our mobile format and understand better how they manage their repositories, we’ll design how the format of our future OSX app.</li></ul><p>Starting a project is an amazing adventure and we’re looking forward to hearing about what our users think about the product and working together as a team to solve this problem with something we’ve developed and designed by ourselves.</p><blockquote><em>If you want to be Beta tester, hear more about the project, or even get involved, do not hesitate to write us, </em><a href="/service/mailto://team@gitdo.io"><em>team@gitdo.io</em></a><em>.</em></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b17550529138" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Create Swift Frameworks with Dido]]></title>
            <link>https://medium.com/@gitdoapp/create-swift-frameworks-with-dido-f269b4dc1d92?source=rss-680a2f7163ea------2</link>
            <guid isPermaLink="false">https://medium.com/p/f269b4dc1d92</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[cocoapods]]></category>
            <dc:creator><![CDATA[GitDo]]></dc:creator>
            <pubDate>Thu, 05 Nov 2015 17:50:34 GMT</pubDate>
            <atom:updated>2015-11-05T17:50:34.834Z</atom:updated>
            <content:encoded><![CDATA[<p>We’ll start our blog with a post explaining how to create new Swift frameworks thanks to a <em>command line tool</em> we have developed called <strong>Dido</strong>.</p><h3>What’s Dido?</h3><p><a href="https://github.com/gitdoapp/dido">Dido</a> is a command line tool developed in Ruby that simplifies all the steps to get a framework project ready, compatible with CocoaPods &amp; Carthage and multi-platform (iOS/OSX/tvOS/watchOS). With a simple command you’ll get the project ready with your provided <em>name</em>, and <em>organization identifier</em>.</p><blockquote><em>We’ve recently been working on multiple libraries, some of them are </em><a href="https://github.com/gitdoapp/soundcloudswift"><em>SoundCloudSwift</em></a><em> and </em><a href="https://github.com/gitdoapp/sugarrecord"><em>SugarRecordSwift</em></a><em> and noticed we repeated the same tasks for setting up each of these libraries and wanted to automatize that somehow.</em></blockquote><h3>Why?</h3><p>We ♥ the tool CocoaPods offers pod lib create but its template is strongly tied to <a href="https://cocoapods.org/">Cocoapods</a>. We wanted something that didn’t actually depend on any dependency manager but that could be integrated using any of them (<a href="https://github.com/carthage/carthage">Carthage</a> or <a href="https://cocoapods.org/">CocoaPods</a>)</p><p><strong>Features</strong> — Implemented on <strong>Ruby</strong> — Supports <strong>iOS/OSX/tvOS/watchOS</strong> — Includes a testing target with (Nimble/Quick)</p><h3>How to use it?</h3><ol><li>Install Carthage and CocoaPods if you didn’t have them installed:</li></ol><ul><li><strong>CocoaPods</strong>: gem install cocoapods</li><li><strong>Carthage</strong>: brew install carthage</li></ul><ol><li>Install dido <strong>gem</strong> with gem install dido</li><li>Create your lib: <em>dido lib MyLib org-id=io.gitdo org-name=GitDo</em></li></ol><p>It’ll create the library under <em>./MyLib</em>, open the .xcodeproj file and start coding</p><p><em>The image below shows the result project with the name prueba</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1010/1*cuqkuTIjQdgW-HNgz6tJjg.png" /></figure><h3>Future Features</h3><p>We’re planning to support multiple templates and specify which one you wan to use during the generation process. If you have any other idea to improve the tool feel free to propose it, or create an issue with it. The tool is open source and opened to all the Swift community. Enjoy it!</p><p>Follow us on Twitter @gitdoapp and stay tuned to our last releases and news.</p><p>Post originally written at <a href="http://blog.gitdo.io/">http://blog.gitdo.io</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f269b4dc1d92" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>