<?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 Philip Engberg on Medium]]></title>
        <description><![CDATA[Stories by Philip Engberg on Medium]]></description>
        <link>https://medium.com/@philipengberg?source=rss-66edf94d18b6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*n-InYxdxtIQ3qOJ5bnnh3A.jpeg</url>
            <title>Stories by Philip Engberg on Medium</title>
            <link>https://medium.com/@philipengberg?source=rss-66edf94d18b6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 08:25:08 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@philipengberg/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[Building flows on Mobile with LEGO bricks]]></title>
            <link>https://medium.com/tonsser/building-flows-on-mobile-with-lego-bricks-34e292410908?source=rss-66edf94d18b6------2</link>
            <guid isPermaLink="false">https://medium.com/p/34e292410908</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[xr]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[kotlin]]></category>
            <dc:creator><![CDATA[Philip Engberg]]></dc:creator>
            <pubDate>Sun, 25 Mar 2018 09:44:22 GMT</pubDate>
            <atom:updated>2018-03-26T10:33:34.918Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GEO1ZOLFS2F6yWbWhRPa2g.jpeg" /></figure><blockquote><strong>Note</strong>: This post mainly uses examples with Swift on iOS, but at the end of this post, examples using <strong>Kotlin on Android</strong> are also provided.</blockquote><p>Flows in mobile apps are ubiquitous these days, yet supporting complex, non-linear flows that have extremely low maintenance and ridiculously high flexibility is not as straight forward as one could hope.</p><p>The Tonsser iOS app has many small and medium sized flows, most of which are more or less linear. However, our product requires our onboarding flow to be very non-linear. At the same time, being a lean and agile startup, we want to be able quickly swap around, swap out or A/B test indivisible steps, or even entire sub flows with a snap of the fingers. There are of course a multitude of ways to attack this problem, but the nature of <a href="http://reactivex.io/"><strong>Rx</strong></a> — handling asynchronous behaviour in linear fashion — is an obvious choice to begin with, and since our app already heavily relies on this paradigm, we endeavoured on a journey to find the ultimate flow management that would be both</p><ul><li>Super easy to implement, maintain, and expand on, and</li><li>Support very high level of complexity in the underlying flow logic</li></ul><h3>The challenge</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iLCC9ctes6DKo-8nvxXTHw.png" /></figure><p>This is the latest iteration of the Tonsser onboarding flow. You might ask: <em>“Well, why are you making it so hard for yourself?”</em>. It’s not because we specifically <em>want </em>to, it’s because… <strong>football</strong> — or soccer, depending on your place of origin ⚽️🌍</p><p>Tonsser is an app for football players to <strong>keep track of their match performances</strong>, among other things. But since this is our main value proposition, we want to present this value to users as early in their journey as possible, so that they understand why Tonsser is useful for them.</p><p>But inputting data about a match requires that the team you played on actually <strong>did play a match</strong> in the <em>past</em>. But matches are only played during the <strong>season</strong>, in a relatively short window, and you may sign up at an arbitrary point in time relative to this. On top of that, in order for you to even be able to input match stats to begin with, you first need to find your real life team, and since we get all this team and match data from third parties, data may sometimes be missing or incomplete, meaning you can’t find your real team, so a lot of <strong>fallback flows</strong> are needed. Oh, and we recently added support for <strong>coaches</strong>, who have their entirely own flow and journey 🤯</p><p>So all in all, there are <strong>many</strong> paths through our onboarding and <em>implementing</em> that flow logic, let alone <em>maintaining</em> and <em>extending</em> it with low cost is a potential nightmare.</p><h3>Rx to the rescue</h3><p>As mentioned, we are huge fans of Rx and use it for almost everything. Rx helps handling asynchronous units of work in a very elegant way and in the case of flows there are two main kinds of asynchronicity:</p><ol><li><strong>👆 The behaviour and interaction of the user:</strong> After displaying a certain step in the flow, it may take an arbitrary amount of time before the user chooses to continue.</li><li><strong>📡 Any network related work associated with performing a step in the flow</strong>: Like POSTing new data to the API once a flow step in finished.</li></ol><p>If you were to use pure Rx for this, one approach could be to let each step expose and observable that internally is kept as a PublishSubject. Then the individual step could call onNext on this whenever it’s done and then have some flow controller subscribe on this and move on to the next step. But we can actually do better than that.</p><h3>Actions</h3><p><a href="https://github.com/RxSwiftCommunity/Action">Action</a> is an abstraction of observables that was carried over from ReactiveCocoa’s RACCommand. It’s a way of deferring a unit of work, which produces an observable, to be executed at any point later in time. This may simply represent a UI interaction <em>or</em> and API request.</p><p>An action is defined as Action&lt;Input, Element&gt; and is initialised with a workFactory defined as</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7119a9d1b3848c0c6ecc6b3963506cd6/href">https://medium.com/media/7119a9d1b3848c0c6ecc6b3963506cd6/href</a></iframe><p>So it’s essentially just an anonymous function that takes one parameter of type Input and returns an observable of type Element. To execute this work factory you simply just call execute() on the Action:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/35b0767e231f89225cf70622c3158b52/href">https://medium.com/media/35b0767e231f89225cf70622c3158b52/href</a></iframe><p>An action then exposes three different observables for you to subscribe on as needed:</p><ol><li><strong>.elements: </strong>Observable&lt;Element&gt; This emits the observable returned by the work factory you defined on initialisation, so the <strong>outputs</strong> essentially.</li><li><strong>.errors: </strong>Observable&lt;Error&gt; This emits any errors that occur in the work factory in a separate observable as next elements, meaning that errors don’t cause the .elements observable to <em>complete</em> and thus lets you observe errors happening infinitely many times.</li><li><strong>.executing: </strong>Observable&lt;Bool&gt; This is a convenient property that is basically meant to bind to a spinner, so that you don’t have to manually show a spinner before you start executing and then stop it if it completes <em>or</em> if it errors.</li></ol><p>Also, actions can only execute one thing at a time, so if the workFactory is already executing (e.g. if an API call is already underway) it will just discard any calls to execute() until it’s done.</p><p>For further convenience the Action comes with a handy extension to UIButton allowing you to bind these two directly together:</p><pre>button.rx.action = action</pre><h3>Actions in flows</h3><p>That’s all great, but how does that fit into flows? 🤔 Since steps in a flow typically end with the user tapping a button, which <em>may</em> make one or more API requests, it would make sense to represent this with actions in each step and then have a separate <strong>flow controller</strong> listening on these in order to know when to move on.</p><p>Consider this simple linear flow:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/937/1*HuctpAx3AuknCWvAFxWfPA.png" /></figure><p>Each step exposes one doneAction and does not know <em>anything</em> about any of the other steps in the flow. Now these three steps can be composited together by flatMaping the doneActions as seen below. Also notice how <strong>only</strong> Step A performs an API request whereas B and C just represent UI interaction, but that the flow controller does not have to know or care about this.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/67c56d1f9217cd7f9255a5113c6b96c4/href">https://medium.com/media/67c56d1f9217cd7f9255a5113c6b96c4/href</a></iframe><p>This is already pretty simple and easy to understand — but so is the flow it’s representing.</p><h3>Non-linear flows</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/964/1*wSfw_AAR4AjTOiM6Olcjgw.png" /></figure><p>Now consider the flow above. Here the user has two options on Step B: A primary option, represented by the doneAction, and a secondary action, represented by the skipAction. Depending on which of these the user selects, different steps will be shown next. This can be achieved by modifying the FlowController as follows:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/28065e3afb75f669b5b4e7538776d404/href">https://medium.com/media/28065e3afb75f669b5b4e7538776d404/href</a></iframe><p>So now Step B handles the forking itself and everything is still relatively simple. But we’re just getting started 😱</p><h3>Shared subflows</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fu9duOy52vzhxJRP7RM3XQ.png" /></figure><p>Now, this is when it starts getting a little annoying to handle 🙄 At different, independent points <em>after</em> a <strong>fork </strong>in the flow, the user will get E, F, and G in <em>that</em> order always. Now we are forced to duplicate flow logic code with a bunch of flatMaps, yuck.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fe81af11cd2fa7e85db146e7bf17ca2b/href">https://medium.com/media/fe81af11cd2fa7e85db146e7bf17ca2b/href</a></iframe><p><em>And</em><strong><em> </em></strong>this is only <strong>one</strong> layer deep in forking complexity — imagine just one or two layers more.</p><h4>Higher order generic functions with infix operator 👀</h4><p>So we want to be able to make a <em>reusable</em> definition of the subflow E, F, and G. So what we need is something that can <strong>composite</strong> an arbitrary number of steps together into a single variable, which can then be executed at any point in the flow. This composite function should take <strong>two</strong> arguments: The function that performs the first step (like showE()) and a function that performs the next step function (like showF()), both of which of course return observables. A flatMap can then be applied to the first function, in which the next one is invoked. If all of this is returned in a wrapping function, this process can be repeated over and over again 😃</p><p>Alright, enough theory. Below is a custom, <em>generic</em> infix operator defined, which takes in two functions as parameters, both of which return observables. Furthermore, the return type of the first function has to fit with the input of the second function in order to be able to chain them together.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/33844ccb8ca0176ec7f23743d6eb165d/href">https://medium.com/media/33844ccb8ca0176ec7f23743d6eb165d/href</a></iframe><p>Using this, we can now define the E, F, G subflow globally and execute at any point in the flow like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d9fd614e59599191f9a551ab4ecc92ba/href">https://medium.com/media/d9fd614e59599191f9a551ab4ecc92ba/href</a></iframe><p>Not only does this <strong>significantly</strong> improve clarity and readability, but if you all of a sudden have to swap around F and G it just takes a few seconds <em>and</em> you only need to do it <strong>once</strong>:</p><pre>let showEGF = showE |&gt; showG |&gt; showF</pre><h3>💥</h3><h3>Concrete example</h3><p>Below is a concrete example from our new onboarding flow. You may use the flow chart in the beginning of this post to get an idea of the purpose of this logic. Early on in the flow, the user has to pick his or her role in the app. <strong>Coaches</strong> and <strong>Players</strong> each have their own full fledged flows, whereas selecting a different role from these simply skips to the <em>shared end flow</em>, which can be seen in forkFlowBasedOnUserRole().</p><p>Similarly, if you <em>did</em> select the <strong>Player</strong> role, you are taken through the joinTeam flow — which, by the way, has its entirely own isolated flow controller setup like the onboarding flow for reuse in-app. This subflow may result in you <em>not</em> finding your team, in which case you are taken to a fallback subflow, which then again is composited together with the <strong>same </strong><em>shared end flow</em> as above 💖</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7a9c5f63c932d372e97de2cec2140ed9/href">https://medium.com/media/7a9c5f63c932d372e97de2cec2140ed9/href</a></iframe><h3>The power of LEGO bricks</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*xLmbl6h6d_6iHIQNF_yTgg.jpeg" /></figure><p>So with the help of Rx, Actions, and the custom infix operator |&gt;, we can piece together incredibly complex flows in a way that is completely abstracted away from the UI and functionality of each step, while being able to maintain, modify, or even A/B test any part of flow logic in little to no time — just like building with <strong>LEGO</strong> <strong>bricks </strong>instead of <strong>wooden sticks</strong> and <strong>hot glue</strong> 🤘</p><h3>Android &amp; Kotlin</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/360/1*lqWm7HsyL0tpu9cygCOgfQ.png" /></figure><p><strong>Kotlin</strong> is in many ways very similar to <strong>Swift</strong>, which makes it easy to share ideas and concepts across iOS and Android.</p><p>That is also what happened in this case. Our Android app is also heavily relying on RxKotlin, so using the Action approach seemed like an obvious choice for this onboarding flow. But after sifting through the World Wide Web, we were left disappointed 😥 So we took matters into our own hands and ported the <a href="https://github.com/RxSwiftCommunity/Action">Swift version</a> ourselves. We of course open sourced it as well and can be found here: g<a href="https://github.com/tonsser/kaction"><strong>ithub.com/Tonsser/KAction</strong></a>.</p><p>The definition of the infix function if very similar to that in Swift:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cddb919a47ce1b8564e2970b1d5c5878/href">https://medium.com/media/cddb919a47ce1b8564e2970b1d5c5878/href</a></iframe><p>It’s an extension of the Function1 type, i.e. functions that take one argument. Kotlin can’t use special characters in function names because of Java interoperability, so we went with a simple then instead 🤓</p><p>In order to pass functions as parameters to other functions in Kotlin, you have to use :: operator. Putting all the pieces together, this is what we end up with:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e963a47667cbd35bca5d8a1ee7d91078/href">https://medium.com/media/e963a47667cbd35bca5d8a1ee7d91078/href</a></iframe><p>Subscribe to the <a href="https://medium.com/tonsser">Tonsser Medium blog</a> to get an in depth story in the near future of how our Android Engineers managed to implement this insanely flexible, yet powerful flow architecture as well 💪</p><blockquote>At Tonsser we seek to change to the world of football using cutting edge technologies. We are constantly looking for daring explorers like <strong>you</strong>, so check out our open positions at <a href="https://tonsser.com/dk/jobs"><strong>tonsser.com/jobs</strong></a>.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=34e292410908" width="1" height="1" alt=""><hr><p><a href="https://medium.com/tonsser/building-flows-on-mobile-with-lego-bricks-34e292410908">Building flows on Mobile with LEGO bricks</a> was originally published in <a href="https://medium.com/tonsser">Tonsser</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What’s in my (iOS Developer) dock ️]]></title>
            <link>https://medium.com/@philipengberg/whats-in-my-ios-developer-dock-%EF%B8%8F-be0f736ba5b5?source=rss-66edf94d18b6------2</link>
            <guid isPermaLink="false">https://medium.com/p/be0f736ba5b5</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[mac]]></category>
            <category><![CDATA[apps]]></category>
            <dc:creator><![CDATA[Philip Engberg]]></dc:creator>
            <pubDate>Mon, 02 Oct 2017 19:58:41 GMT</pubDate>
            <atom:updated>2017-10-02T19:58:41.310Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7as20beoSanmTsokYMDodw.png" /></figure><p>Though I would love to write about <strong>SpaceX</strong> and all their crazy ambitions, this is a bit more down to Earth 🌍</p><p>I just quickly want to share the apps I use the most in my daily life as an iOS Developer, so I hope you’ll be inspired to try out something new 🌟</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/256/1*fAaSQJnnhtH74KJ5Pb3A_A.png" /></figure><h3>Spark</h3><p>Though email is something I try to stay away from in general, you still need it when reaching out to external contacts. But 90% of my email probably consists of reminders, notifications and what not from the different services I have an account on. That’s where <a href="https://sparkmailapp.com/">Spark</a> comes in: Spark has a “Smart Inbox” that puts your email into three different categories (optionally across email accounts too 👏)</p><ul><li>Personal</li><li>Notification</li><li>Newsletters</li></ul><p>It thus filters away all the noise and gives you a bit of breathing space. You can also <strong>snooze</strong> mails and have Spark remind you about it at a later point.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/529/1*rs9ydLF5r_RQbSpKJSGtnQ.png" /><figcaption>Smart inbox sort emails into useful categories</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/256/1*GR87K1abuyki57bQqkKucw.png" /></figure><h3>SourceTree</h3><p>I’m a visual kind of guy — I know my git commands in the terminal, of course, but I prefer the visual overview.</p><p>There are many such clients out there and I have tried most of them. My biggest issue with many of them is that they try to make git fancy, with flashy UI elements that just makes it harder to use. I have therefore settled with <a href="https://www.sourcetreeapp.com/">SourceTree</a> by Atlassian so far. It’s simple and <strong>utilitarian</strong>. I provides a to-the-point overview of all the important things:</p><ul><li>Branches</li><li>Commit history</li><li>Commit diffs</li><li>Tags</li><li>Stashes</li></ul><p>What I actually love the most is the <strong>key bindings</strong> for almost all the regular commands like commit, push, fetch, pull, git flow etc., which makes git super fast to use 💪</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h4rYBORK2fwNvph8cWFQIQ.png" /><figcaption>SourceTree provides a nice and simple overview</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/256/1*8mdagzON0ieWllJhkjZqkg.png" /></figure><h3><strong>Bear</strong></h3><p>This note taking app popped out of the blue on the Mac App Store one day and I downloaded it and tried it out. It was 💖 at first note.</p><p>My visual preference also means that I love <strong>markdown.</strong> It formes a (somewhat) standard syntax that makes it really easy and convenient to transform plain text to nicely formatted and structured documents. Bear’s primary focus on this won me over immediately.</p><p>Bear also uses a unique approach to structuring your notes with <strong>hashtags</strong> into two levels. So#tonsser/ios would put the note in the iossubgroup undertonsser.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BA2EEoUgBfkVw7SWi7OBIQ.png" /><figcaption>Bear supports most markdown elements</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/256/1*3iMUeBSUH_E5QqNwQ6h5Og.png" /></figure><h3>Zeplin</h3><p>Translating designs into reality is what we as iOS Developers do most of the time. Exporting assets and getting precise measurements of interim element placement is crucial and can be a pain with many tools.</p><p>Our design team at Tonsser uses <a href="https://www.sketchapp.com/">Sketch</a>, which easily exports designs into <a href="https://zeplin.io/">Zeplin</a>. From here designs can be grouped into both <strong>tags</strong> and <strong>groups</strong>. Each screen lets you highlight any element to see its placement relative to any other parent, sibling, or child element. If the element has been marked as <strong>exportable</strong> in Sketch, Zeplin makes it possible to export the element as an asset directly into the Xcode asset catalog — both as <strong>bitmap </strong>(1x, 2x, 3x) or as <strong>vector</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rr7EdyO7sScpHLgtsnEDyw.png" /><figcaption>Designs can be grouped into feature or sprints</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4KX2r7h3m6ZZG4FXBNO5YA.png" /><figcaption>Easily get information about layout and export assets directly to Xcode</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/256/1*WNIAKsUatdj5TpILrWZNOw.png" /></figure><h3>Reveal</h3><p>Debugging complex view hierarchies has historically been a hassle for iOS developers, with crazy custom console logs, pink colouring of views, and other creative hacks 🤓</p><p>Luckily <a href="https://revealapp.com/">Reveal</a> changed this dramatically. Including a simple pod in your project you can <strong>inspect</strong> any views in your app and <strong>all</strong> of its properties on both the simulator and real devices. You can even change these properties inside Reveal and immediately see the effect on your device.</p><p>This is an <strong>essential</strong> tool when that annoying view is not showing and it turns out isHidden was set to true 😅</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xSAhmhhCycWcg8TsN8US7A.png" /><figcaption>Reveal provides an amazing overview and insight into your view hierarchy</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/256/1*TXx7KFmIq9U_068JY2yOeQ.png" /></figure><h3>Charles</h3><p>Similarly to view debugging, inspecting the different <strong>network</strong> traffic your app produces and finding out why that model isn’t inflated the way you expected from your API, can be a huge struggle filled with verbose logging statements and breakpoints.</p><p><a href="http://charlesproxy.com/">Charles</a> networkproxy enables you to inspect any network traffic on your computer or even iOS device. If your API uses <strong>SSL encryption</strong> (which they should!) you just install a Charles self-signed SSL certificate on your device allowing you to inspect the HTTPS traffic.</p><p>You can filter requests to only show those from your API and see them as they come in in chronological order. For each request you can of course inspect request headers and bodies, but most importantly the <strong>response</strong> you get.</p><p>This is only the tip of the iceberg. You can also do things like network throttling, copy cURLs to your API developers, repeat request, and all sorts of advanced network tinkering 🛠</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U1jWjkkiOFRLnXhnF0Dmyg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/256/1*TcCKpwcE-Ed4I-N9NXVYTQ.png" /></figure><h3>iStat Menus</h3><p>Running all these apps — often at the same time — requires a lot of sometimes scarce resources on your computer. Keeping track of this can be incredibly valuable. Sometimes RAM is running low, some background process has gone rogue and eats up your CPU, or the network is suddenly slow because your connection has dropped.</p><p>All of these things are surfaced with the amazing toolbar app <a href="https://bjango.com/mac/istatmenus/">iStat Menus</a>. Extremely <strong>customizable</strong>, you can show anything and everything about what your Mac is up to at any given second. Personally I have chosen to show CPU, RAM, network, CPU temp and fan speed, and weather — yeah, sounds a little random, but it’s actually super useful 🌤</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/216/1*yBoNuFGfG7PzlyiWuNSLfQ.png" /></figure><p>For each type of menu item you can deep dive into all kinds details and historic graphs.</p><blockquote>Expanding the “Sensors” menu will definitely <strong>surprise</strong> you with just how many temperature sensors are in your Mac 🕵</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wfhGAa-vGsY_CgV7i8VZ5Q.png" /></figure><h3>Summary</h3><p>I hope you found this brief insight into <em>my</em> most used apps useful. I’d love to see what <strong><em>you</em></strong> carry in your iOS Developer toolbelt, so hit the comments or <a href="https://medium.com/new-story">make your own post</a> and send a link 🙌</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=be0f736ba5b5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How I nailed App Store screenshot automation ]]></title>
            <link>https://medium.com/tonsser/how-i-nailed-app-store-screenshot-automation-8e3c47c00589?source=rss-66edf94d18b6------2</link>
            <guid isPermaLink="false">https://medium.com/p/8e3c47c00589</guid>
            <category><![CDATA[app-store-optimization]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[fastlane]]></category>
            <category><![CDATA[xcode]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Philip Engberg]]></dc:creator>
            <pubDate>Mon, 15 Aug 2016 09:14:12 GMT</pubDate>
            <atom:updated>2016-08-16T15:04:26.695Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w4C-KTwdgwM3cQiw-qS8Hw.png" /></figure><p>Maybe you are one of those lucky guys who only has an English version of your app’s screenshots on the App Store. Maybe you don’t even have five screenshots per screen size. In that case: Appreciate it 🏆.</p><p>In any case, follow along to see how you can achieve 100% text <em>and</em> <strong>data localized</strong> App Store screenshots at the tap of <strong>ONE BUTTON</strong> (seriously).</p><h3>Prolog</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2Fl41YtZOb9EUABnuqA%2Ftwitter%2Fiframe&amp;src_secure=1&amp;url=http%3A%2F%2Fgiphy.com%2Fgifs%2Fl41YtZOb9EUABnuqA&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fl41YtZOb9EUABnuqA%2Fgiphy.gif&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="326" frameborder="0" scrolling="no"><a href="https://medium.com/media/823eecf870a6d306d66d0dd8aae53ca1/href">https://medium.com/media/823eecf870a6d306d66d0dd8aae53ca1/href</a></iframe><p>At <a href="http://tonsser.com/">Tonsser</a> we are currently <a href="https://itunes.apple.com/dk/app/tonsser/id963163548">live</a> in <strong>6</strong> countries around Europe. As most other apps out there we have <strong>5</strong> beautiful screenshots on the App Store and of course, these are represented in all of the <strong>4</strong> different iPhone screen sizes.</p><p>Some quick math reveals that we currently have to maintain <strong>120 </strong>screenshots, adding another <strong>20 </strong>for each new country. On top, our platform relies on being very <strong>local</strong>, so we cannot use a pale, blond haired Scandinavian boy 👦🏼 as the profile picture in the Spanish App Store and vice versa. Just like having a first name like Raul is rather uncommon in the northern parts of Europe 👦🏾.</p><p>It is therefore not enough to just automate the process of taking screenshots in the 6 different locales with the same data set. The actual <em>data</em> also has to be localized.</p><h3>Slave labor</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FogjqmpBZm4Kkg%2Ftwitter%2Fiframe&amp;src_secure=1&amp;url=http%3A%2F%2Fgiphy.com%2Fgifs%2Fhome-ogjqmpBZm4Kkg&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FogjqmpBZm4Kkg%2Fgiphy-downsized-large.gif&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="326" frameborder="0" scrolling="no"><a href="https://medium.com/media/18220f11c3584f37c11756b2e2349095/href">https://medium.com/media/18220f11c3584f37c11756b2e2349095/href</a></iframe><p>Since the beginning, when we only supported one country 🇩🇰, all of this work was done by hand by our talented designers. But mistakes often happened during this manual process; copy/paste errors was inevitable and every time we updated the design they had to start all over. The amount of resources needed to maintain an ever increasing amount of screenshots started to justify looking into full automation of this.</p><h3>Liberating the slaves</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FYaY85YEBWukrm%2Ftwitter%2Fiframe&amp;src_secure=1&amp;url=http%3A%2F%2Fgiphy.com%2Fgifs%2Ffinger-perspective-ferris-wheel-YaY85YEBWukrm&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FYaY85YEBWukrm%2Fgiphy.gif&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="244" frameborder="0" scrolling="no"><a href="https://medium.com/media/2ff11b81969778bdeae08d9dae4503b8/href">https://medium.com/media/2ff11b81969778bdeae08d9dae4503b8/href</a></iframe><p>For a long time I had personally wanted to experiment with automating this process. Seeing the tears on the cheeks of our designers 😢 every time we had to update a screenshot finally gave me the motivation to do something about it. I also knew that <a href="https://fastlane.tools/"><strong>Fastlane</strong></a> had already done most of the heavy lifting with <a href="https://github.com/fastlane/fastlane/tree/master/snapshot#readme"><strong>snapshot</strong></a>, which uses Xcode UI Testing to navigate your app in different languages and the take screenshots at the right time. However, this tool did not assist in showing customizable, localized <strong>data</strong>. Some <strong>home brew</strong> was needed 🍺.</p><h3>Solution 👉 Hyper Localization</h3><p>So two things are needed in order to localize the data:</p><ul><li>A <strong>data template</strong> with placeholders for each localized data point</li><li><strong>Translations</strong> to fill out these placeholders in the template</li></ul><h4>Mock JSON</h4><p>In our project we currently use <a href="https://github.com/Moya/Moya"><strong>Moya</strong></a> as the backing network layer. This library supports the use of mock data out of the box, which makes it super easy to just add localized JSON files for each view that needs screenshot. A template for such a view could look as follows for the Profile:</p><pre>{<br>  &quot;response&quot;: {<br>    //...<br>    &quot;firstname&quot;: &quot;<strong>{snapshot.main_user.firstname}</strong>&quot;,<br>    &quot;lastname&quot;: &quot;<strong>{snapshot.main_user.lastname}</strong>&quot;,<br>    &quot;facebook_id&quot;: &quot;<strong>{snapshot.main_user.facebook_id}</strong>&quot;,<br>    //...<br>    &quot;team&quot;: {<br>      &quot;club_name&quot;: &quot;<strong>{snapshot.main_user.club_name}</strong>&quot;<br>    }<br>  }<br>}</pre><p>And like this for the league table:</p><pre>{<br> &quot;response&quot;: [<br>  {<br>    &quot;team&quot;: {<br>      &quot;club_name&quot;: &quot;<strong>{snapshot.league_table.first_club_name}&quot;<br>    </strong>},<br>    &quot;played_matches&quot;: 13,<br>    &quot;goal_difference&quot;: 35,<br>    &quot;points&quot;: 36<br>  },<br>  {<br>    &quot;team&quot;: {<br>      &quot;club_name&quot;: &quot;<strong>{snapshot.league_table.second_club_name}&quot;<br>    }</strong>,<br>    &quot;played_matches&quot;: 13,<br>    &quot;goal_difference&quot;: 47,<br>    &quot;points&quot;: 32<br>  },<br>  //...<br> ]<br>}</pre><h4>Filling in the blanks</h4><p>The fact that we currently use <a href="https://phraseapp.com/"><strong>PhraseApp</strong></a> for translating our app UI strings combined with their excellent <a href="https://phraseapp.com/docs/api/v2/">API</a> made it an obvious choice to also use this tool to localize the placeholders in the templates above.</p><p>To utilize this API the choice of programming language landed on <strong>Ruby</strong> for multiple reasons:</p><ul><li>It is completely new to me - ️❤️ learning new things</li><li>The entire Fastlane tool is written in Ruby, making it easier to do more custom stuff with our deployment tool at a later point 📈</li><li>Our backend is written in Ruby so should everything fail I would have great support 🛠</li></ul><p>After a ton of Google searches and Stack Overflow questions the solution was quite simple.</p><ol><li>Load the template</li><li>Iterate through translation keys</li><li>Make a new JSON file for each locale</li><li>Fill in placeholders with the translations of each key in each JSON file</li></ol><p><em>Disclaimer: This is newbie Ruby </em>😄 <em>Suggestions are welcomed </em>🙏</p><pre>def replace_texts(file_name, translation_keys, project_id)</pre><pre>  # Load template<br>  template = File.read(&quot;./snapshot/mockdata/#{file_name}.json&quot;)</pre><pre>  # Fetch all snapshot related PhraseApp keys<br>  translation_keys.each do |key|</pre><pre>  # Fetch all translations for current key<br>  translations = request(project_id, key)</pre><pre>    # Iterate all translations<br>    translations.each do |translation|<br>      <br>      # Retrieve data<br>      locale = translation[&quot;locale&quot;][&quot;name&quot;]<br>      value = translation[&quot;content&quot;]<br>      key_name = translation[&quot;key&quot;][&quot;name&quot;]</pre><pre>      # Figure out where to put the data<br>      target_file_name = &quot;/Snapshot/#{file_name}-#{locale}.json&quot;</pre><pre>      # Replace translation key with the translation<br>      template = template.gsub(&quot;{#{key_name}}&quot;, &quot;#{value}&quot;)</pre><pre>      # Write to file<br>      File.open(target_file_name, &quot;w&quot;) do |file|<br>        file.write(base)<br>        file.close <br>      end</pre><pre>    end<br>  end<br>end</pre><p>This results in a large number of JSON files that are added to the Xcode project and are simply read by Moya instead of making the normal network request:</p><pre>private var snapshoatSampleData : NSData {<br>  <br>  switch self {<br>  case .User:<br>    let path = pathForCurrentLocale(fileName: &quot;user&quot;)<br>    return NSData(contentsOfFile: path)!</pre><pre>  case .LeagueRankingTable:<br>    let path = pathForCurrentLocale(fileName: &quot;league&quot;)<br>    return NSData(contentsOfFile: path)!<br>  }</pre><pre>}</pre><h4>Fastlane Snapshot</h4><p>Using the excellent Snapshot tool in fastlane it is super easy to set up the screenshot process with a tiny bit of configuration:</p><pre>devices([<br>  &quot;iPhone 6s&quot;,<br>  &quot;iPhone 6s Plus&quot;,<br>  &quot;iPhone 5s&quot;,<br>  &quot;iPhone 4s&quot;,<br>])</pre><pre>languages([<br>  &quot;en-US&quot;,<br>  &quot;da&quot;,<br>  &quot;sv&quot;,<br>  &quot;no&quot;,<br>  &quot;es-ES&quot;,<br>  &quot;it&quot;,<br>  &quot;fr-FR&quot;,<br>])</pre><p>and a few lines of UI Testing code:</p><pre>XCUIApplication().tabBars.buttons.elementBoundByIndex(2).tap()<br>snapshot(&quot;1_Profile&quot;)</pre><pre>XCUIApplication().tabBars.buttons.elementBoundByIndex(1).tap()<br>snapshot(&quot;4_League&quot;)</pre><h3>The Golden Overview</h3><p>Here’s a simple illustration of each step in the process detailed above:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PU4AgrEDELHinF9WCKBFMw.png" /></figure><h3>Push the button</h3><p>And with that, it is now time to hit that <strong>Big Red Button 🚀</strong></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FGwRBmXyEOvFtK%2Ftwitter%2Fiframe&amp;src_secure=1&amp;url=http%3A%2F%2Fgiphy.com%2Fgifs%2Fbig-push-button-GwRBmXyEOvFtK&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FGwRBmXyEOvFtK%2Fgiphy.gif&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="326" frameborder="0" scrolling="no"><a href="https://medium.com/media/522bb272678b281c5ffae38e15dfe1c7/href">https://medium.com/media/522bb272678b281c5ffae38e15dfe1c7/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/130/1*s1JPrNvAhBDtzIUyh94N_w.png" /></figure><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fplayer.vimeo.com%2Fvideo%2F178452032&amp;url=https%3A%2F%2Fvimeo.com%2F178452032&amp;image=http%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F586086763_1280.jpg&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=vimeo" width="1920" height="1080" frameborder="0" scrolling="no"><a href="https://medium.com/media/843e94ead6ee8efa944555c659d400b3/href">https://medium.com/media/843e94ead6ee8efa944555c659d400b3/href</a></iframe><p>Resulting in completely different screenshots for each screen size and locale.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-AkG-RsIfk2NH1L3sGwTUg.png" /></figure><h3>Nailed it 💪</h3><p>All it now takes to add a new country/locale is to “translate” the related PhraseApp strings and then hit that <strong>Big Red Button</strong> again. Same goes when the design is tweaked or when translations have been updated: <strong>1 button</strong> 👉 <strong>120+ screenshots</strong> 😎</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FmsKNSs8rmJ5m%2Ftwitter%2Fiframe&amp;src_secure=1&amp;url=http%3A%2F%2Fgiphy.com%2Fgifs%2Fday-subreddit-msKNSs8rmJ5m&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FmsKNSs8rmJ5m%2Fgiphy.gif&amp;key=d04bfffea46d4aeda930ec88cc64b87c&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="323" frameborder="0" scrolling="no"><a href="https://medium.com/media/80795190a202decbdb650292cd620bb7/href">https://medium.com/media/80795190a202decbdb650292cd620bb7/href</a></iframe><h3>Epilog</h3><p>The attentive reader might have also noticed that this procedure will result in an accumulated amount of more or less duplicate JSON files in the Xcode project, thus unnecessarily increasing the size of the app bundle. However, I also made a small script that purges the contents of these files after taking all the screenshots, allowing the files to still be part of the project without increasing the app size significantly.</p><p>Apple also just recently <a href="https://developer.apple.com/news/?id=08082016a">announced</a> a simplified screenshot upload process for iTunes Connect, which makes it possible to upload just one set of screenshots to be used across localizations and scaled to other screen sizes. However, in our case at least, we <strong>need</strong> the localization for our product. Also, if your UI does not scale linearly across screen sizes, you would probably still want different screenshots for each screen size.</p><p><em>If there’s enough interest for the complete source, I’ll post it, so let me know in the comments below </em>🙌</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8e3c47c00589" width="1" height="1" alt=""><hr><p><a href="https://medium.com/tonsser/how-i-nailed-app-store-screenshot-automation-8e3c47c00589">How I nailed App Store screenshot automation 🚀</a> was originally published in <a href="https://medium.com/tonsser">Tonsser</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>