<?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[Itty Bitty Apps - Medium]]></title>
        <description><![CDATA[Stories from the team at Itty Bitty Apps - Medium]]></description>
        <link>https://medium.com/itty-bitty-apps?source=rss----4b4f26e2e28e---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Itty Bitty Apps - Medium</title>
            <link>https://medium.com/itty-bitty-apps?source=rss----4b4f26e2e28e---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 15:56:06 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/itty-bitty-apps" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Unit Tests and Working with Legacy Code]]></title>
            <link>https://medium.com/itty-bitty-apps/unit-tests-and-working-with-legacy-code-c32fd7c3e64e?source=rss----4b4f26e2e28e---4</link>
            <guid isPermaLink="false">https://medium.com/p/c32fd7c3e64e</guid>
            <category><![CDATA[xcode]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[swift-playgrounds]]></category>
            <category><![CDATA[xctest]]></category>
            <dc:creator><![CDATA[Ben Thomas]]></dc:creator>
            <pubDate>Fri, 11 Nov 2016 04:53:04 GMT</pubDate>
            <atom:updated>2016-11-11T05:18:32.874Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SjkHIIWstXMU1xKY8Nh7KA.jpeg" /></figure><p>Much has been written about writing good software and how to refactor a codebase when you want to add or remove features but most of the existing literature uses C or Java in it’s examples. Here I will attempt to show how iOS Developers can use XCTest to aid in maintaining legacy Swift code.</p><h3>What is legacy code?</h3><p>Legacy code is basically any existing code — it doesn’t matter how old it is. But the older it is, the less likely you are to be familiar with it — even if you wrote it. And you want to be able to modify it with confidence that you won’t break existing functionality.</p><h3>What are we trying to achieve?</h3><p>There are many reasons for having to touch legacy code but they generally fall into the following categories:</p><ul><li>Fix a bug</li><li>Change the behaviour due to a change in business rules</li><li>Extend the functionality to support a new feature</li></ul><p>If we’re lucky we don’t need to make any major changes to do any of the above, but often we need to refactor the code to achieve our goal. This could be as simple as taking a few lines of code and extracting them to a separate function, or as complicated as breaking an object up into several separate objects, resulting in the need for changes throughout the codebase wherever the old code was called from.</p><p>The problem is, we don’t want to introduce any bugs, and unless we’re intimately familiar with the app, or the codebase is very simple, it’s highly likely that we will break something.</p><h3>Unit tests are our friend</h3><p>Before we go changing any code it’s important to be sure we understand how the app functions first and be able to know if we’ve changed that functionality after we’ve changed the code.</p><p>So that I can demonstrate how unit tests can help, lets imagine we have an app that can display the name and address of a person in a UILabel. We’ll have a simple Person object and a view model with a single function that returns the text for the label.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/711004e744eb519a0378fd4720084043/href">https://medium.com/media/711004e744eb519a0378fd4720084043/href</a></iframe><p>Step 1 is to understand what this code does by writing a failing test.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7a9dae6dedda1e4afeacec4afb1f8d22/href">https://medium.com/media/7a9dae6dedda1e4afeacec4afb1f8d22/href</a></iframe><p>This will fail with an error:</p><pre>XCTAssertEqual failed: (“John Appleseed, 1 Infinite Loop, Cupertino, CA”) is not equal to (“”) —</pre><p>To make our test pass we can copy the output string into the test case:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/06acf02db0c3b09df96acb587ddae2ba/href">https://medium.com/media/06acf02db0c3b09df96acb587ddae2ba/href</a></iframe><h3>Refactoring</h3><p>Now that we have a unit test, we can start to refactor. So lets say we want to split the name into two separate properties on the Person class, so we can display them in two separate labels on another screen in our UI. But we still want to display the original label and we need to be sure that the existing behaviour hasn’t been broken.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1c939a53f3cea106099add5bbd54e4c4/href">https://medium.com/media/1c939a53f3cea106099add5bbd54e4c4/href</a></iframe><p>And lets get the code compiling by updating the view model too:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/81db5778d3bf1224ff802a79d374bbfa/href">https://medium.com/media/81db5778d3bf1224ff802a79d374bbfa/href</a></iframe><p>When we run the test we’ll discover we’ve introduced a bug in the formatting of the output text because we forgot to put a space between the first name and the last name:</p><pre>XCTAssertEqual failed: (“<strong>JohnAppleseed</strong>, 1 Infinite Loop, Cupertino, CA”) is not equal to (“<strong>John Appleseed</strong>, 1 Infinite Loop, Cupertino, CA”) —</pre><p>This is a really basic example, but it shows how writing a unit test first can help us make sure we don’t create bugs when we refactor our code. It’s worth pointing out here that this test would have been much harder to write if the code to generate the name and address string was inside a view controller. It’s a good example of the kind of logic that should live inside a view model object. <a href="https://www.objc.io/issues/13-architecture/mvvm/">MVVM</a> — Model, View, View Model — is a very handy pattern to follow if you have logic that you’d like to unit test. But if you have your logic in a view model and it’s still hard to test, then that indicates your code should be refactored. That could involve extracting the logic to separate objects, or splitting the logic into separate testable functions. A topic for another post.</p><h3>Acknowledgements</h3><p>Adding unit tests for legacy functionality is just one strategy for dealing with modifying legacy code. For details of other strategies and techniques I recommend <a href="https://amzn.com/0131177052">Michael Feather’s book “Working Effectively with Legacy Code.”</a></p><p>While writing this post I used a <a href="https://gist.github.com/iosdevben/3bce3170925ff1b3e82d24e25d5876de">Playground</a> and I learned how to get XCTests to run within the playground, thanks to Stuart Sharp’s post about <a href="http://initwithstyle.net/2015/11/tdd-in-swift-playgrounds/">TDD in Swift Playgrounds</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qtwi6-ZnEe2_i-bdd1ImOA.png" /></figure><p><em>Based in Melbourne, Australia, </em><a href="http://ittybittyapps.com/"><strong><em>Itty Bitty Apps</em></strong></a><em> builds great software on mobile and Mac for clients big and small. It also makes </em><a href="https://revealapp.com/"><strong><em>Reveal</em></strong></a><strong><em> </em></strong><em>— Amazingly powerful runtime view debugging for iOS developers.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c32fd7c3e64e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/itty-bitty-apps/unit-tests-and-working-with-legacy-code-c32fd7c3e64e">Unit Tests and Working with Legacy Code</a> was originally published in <a href="https://medium.com/itty-bitty-apps">Itty Bitty Apps</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Taking Revert to tvOS]]></title>
            <link>https://medium.com/itty-bitty-apps/taking-revert-to-tvos-ca2c2867fd1c?source=rss----4b4f26e2e28e---4</link>
            <guid isPermaLink="false">https://medium.com/p/ca2c2867fd1c</guid>
            <category><![CDATA[apple-tv]]></category>
            <category><![CDATA[tvos]]></category>
            <category><![CDATA[reveal]]></category>
            <dc:creator><![CDATA[Brunno Ferreira]]></dc:creator>
            <pubDate>Thu, 13 Oct 2016 04:14:07 GMT</pubDate>
            <atom:updated>2016-10-13T08:53:43.110Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8ilGokhLfPQR-AV3v81GTA.png" /></figure><p>To make sure we take support for tvOS on <a href="http://revealapp.com/">Reveal</a> even further, we recently updated <a href="https://github.com/revealapp/Revert">Revert</a>, adding compatibility with this new Apple platform.</p><p>As explained on <a href="http://revealapp.com/blog/announcing-revert.html">the Reveal.app blog</a>, Revert is an open source project that comprises a series of common and edge case scenarios that help us optimize <a href="http://revealapp.com/">Reveal</a> and ensure its quality with every update, making sure there are no regressions being introduced.</p><p>Coming from the iOS and macOS worlds, here’s what we learned from working with tvOS:</p><h4>Focus Engine</h4><p>This is probably the most noticeable change when starting tvOS development. Interface elements aren’t meant to be pointed at with a mouse or touched with your fingers, but are instead focused on a TV across the room according to movements on a touch surface on the Siri Remote.</p><p>Focusing a view brings it forward, making it more prominent. Only a single object can be focused at a time. Previously, the only focusable objects were views, but <a href="https://developer.apple.com/library/prerelease/content/releasenotes/General/WhatsNewinTVOS/Articles/tvOS10.html#//apple_ref/doc/uid/TP40017259-SW1">support for this has been extended to non-view items on tvOS 10</a>.</p><p>So just like you would use the arrow keys on your computer keyboard to move selection between different files or folders, you now bring a button into focus on your TV and make it the frontmost element. In both cases, you know that that’s the item you will be interacting with when proceeding with the default selection action — be it a key press or a tap on the Siri Remote.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QTbMBOhGSTZwa6pgl8llXQ.jpeg" /><figcaption>Yes, please do check out the SpriteKit example!</figcaption></figure><p>When using most of the controls available on tvOS you get that behavior for free, since they come with sensible defaults that make the focus engine change their appearance automatically. But that is not the same when using standard UICollectionViewCells.</p><p>So, let’s say you are a very attentive iOS developer and noticed most of the apps on the TV have UIs that resemble collection views. That seems like a good starting point, right? Thus, you quickly set up a project with a simple collection view and default cells to start playing with the OS and nothing gets focused.</p><p>It turns out that is the expected behavior, since collection view cells are composed of ordinary views. You need to use the <a href="https://developer.apple.com/library/tvos/documentation/UIKit/Reference/UICollectionViewDelegate_protocol/index.html">collection view delegate</a> to update the look of each cell when adding or removing focus. Or, as an easy way around that, design your cells using UIImageViews. By default, they will animate their images in and out of focus when placed as subviews of focusable elements.</p><p>If you’d like to get more technical details about the focus engine and what is possible, the Airbnb developers have some great material <a href="http://nerds.airbnb.com/tvos-focus-engine/">here</a>.</p><h4>Sideways, not Downwards/Upwards</h4><p><a href="https://medium.com/u/a13a8e7a26e6">Michael Flarup</a> said it best on <a href="https://medium.com/@flarup/designing-for-the-apple-tv-5992c3aab1e4#.93ybrn3sy">Designing for the Apple TV</a>: the natural interaction on tvOS is moving the selection around elements — as opposed to smartphone touch screens where entire views get scrolled.</p><p>When more content needs to come up or down as a result of a vertical gesture, the whole interface might need to get redrawn, which means the user could potentially get disoriented for a moment while trying to get acquainted with the changes on the screen. Horizontal gestures, on the other hand, usually require redrawing just the related elements that sit side by side.</p><p>Based on that approach, we built Revert based on a split view with categories on the master view and test scenarios on the detail view. Scrolling up and down on the list to the left refreshes all the entries to the right — but browsing a single category to the right does not change anything else on the screen. Additionally we need to test tvOS split views with Reveal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JNNjFjHLT7HQ7e-dRrvt7Q.jpeg" /><figcaption>Vertical scrolling on the master view refreshes the whole detail view</figcaption></figure><h4>Remote Coordinates System</h4><p>The Siri Remote (as well as game controllers connected to the Apple TV) can handle touches in windowing mode or interpret their absolute values.</p><p>To read absolute touch points (where exactly the user touched on the touch surface) we need to use the GCMicroGamepad profile, signaling that the remote will be used as a game controller. Otherwise tvOS defaults to windowing mode, like what happens on the SpriteKit example in Revert.</p><p>When using windowing, initial touches on the Siri Remote are always considered the origin (0, 0). So it does not really matter if the gesture starts on the bottom left corner or on the top right corner of the touch surface on the remote. We just start reading finger movement from there.</p><p>Unlike on iOS, where the user directly manipulates the interface, on tvOS the user interacts with the Siri Remote — which is one level removed from the interface on screen. This means the user is likely not facing the interaction controls, and thus the concept of the initial touch being “flexible” and gestures starting from there becomes fundamental for building a good user experience.</p><h4>Missing Controls and Frameworks</h4><p>Everyone has been making quite a fuss about the absence of UIWebView (or WKWebView) and the Safari View Controller, but there’s more stuff from iOS that didn’t make it to tvOS, like UIToolbars, UIPickerViews, UISliders and UISteppers. MapKit was also absent at launch, but was subsequently included in tvOS 9.2 and is already a part of Revert — check it out to see where all of us here at Itty Bitty Apps come from.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dNcP9JgT0esdq7qgg2febA.png" /><figcaption>That’s us!</figcaption></figure><p><a href="https://developer.apple.com/library/tvos/releasenotes/General/tvOS90APIDiffs/index.html">Many frameworks are not included in tvOS</a>, although many of them do not make much sense anyway because the Apple TV lacks the hardware required.</p><p>So if you plan on porting an iOS app to tvOS, it is worth checking if all the components you require are either available or can be replicated in some fashion. As an example, Apple implements the language selector in the Settings app (a common use for pickers) as a UIAlertController with many options.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0qWn3uyr3Ry3G4SkF5LJrw.png" /><figcaption>Language selector in tvOS 9.2 inspected on Reveal: UIAlertController with many, many options</figcaption></figure><h4>Reuse Code, Not Storyboards</h4><p>If you’re porting an iOS app to tvOS and have got at least a few non-trivial views, this is probably one of the biggest pain points in your endeavor. Storyboards are not interchangeable, and you can’t even copy and paste specific elements between the platforms.</p><p>After screaming, crying and flipping a few tables, it is hard not to agree at least in part with that decision though. Since not all the controls from iOS are available on tvOS, it makes sense to have storyboards specific to each platform.</p><h4>Local Storage</h4><p>Most people will say there is no local storage for a tvOS app, but that is not really the case. Here’s what Apple says about it:</p><blockquote>(…) your app can only access 500 KB of persistent storage that is local to the device (using the NSUserDefaults class).</blockquote><p>So there is local storage available, but it is limited to what can be done with the NSUserDefaults class. If your needs go beyond that, then saying there is no local storage is accurate.</p><p>And in that case, doing it online is the only way to go. Be it CloudKit or any other cloud service.</p><h4>Binary Size</h4><p>There’s also a limit on app binaries. They can’t go over 200 MB, which means using the on-demand resources API <a href="https://developer.apple.com/videos/play/wwdc2015/214/">introduced on iOS 9</a> for anything that can’t get bundled in the app.</p><p>Since, as mentioned previously, there’s no local storage for anything other than NSUserDefaults, this also means you might need to keep fetching assets every time the app is run. Apple makes this clear:</p><blockquote>The maximum size of an Apple TV app is limited to 200 MB. (…) all other data must be purgeable by the operating system when space is low.</blockquote><h4>Top Shelf</h4><p>Apps placed on the top row on tvOS can take advantage of the <a href="https://developer.apple.com/tvos/human-interface-guidelines/#top-shelf">top shelf</a> — a TV Extensions Service that allows exposing contents of the app on the home screen.</p><p>Content presented on the top shelf is a combination of a static banner used as the background and dynamic items that can be interacted with by users. You have no control over where your app icon is placed on the user’s home screen, so every app has to be prepared for being placed on the top row:</p><blockquote>At a minimum, every app must supply a single, static top shelf image that can be displayed when your app is in the top row of the Home screen and in focus.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S_kPPvs0yIZSRDhau6FE8A.jpeg" /><figcaption>Top shelf is an effective way to bring attention to your app.</figcaption></figure><h4><strong>Overscan</strong></h4><p>Last, but definitely not least, there’s <a href="https://en.wikipedia.org/wiki/Overscan">overscan</a>. This can be a gigantic issue if not considered initially or, even worse, completely neglected.</p><p>Surprisingly, there hasn’t been much mention of overscan when people talk about tvOS. But the truth is, there should be. iOS and macOS developers are used to knowing where their apps are going to be run and how that hardware behaves. That simply isn’t the case with tvOS.</p><p>Although Apple TVs may work the same and only differ in storage capacity, there is no way of telling what kind of TVs will be displaying your app. Some may have overscan enabled, some may not. Some may allow disabling overscan, some may not. And having overscan enabled means you should not be using the whole screen estate do draw your app. Never place important content too close to the edges.</p><p>If you are coming from the game console world, it may be natural to consider the <a href="https://en.wikipedia.org/wiki/Safe_area_(television)">TV Safe Area</a> when thinking about your visual design. But as iOS developers, we don’t expect our layout to be simply clipped at the edges of the display.</p><p>Different TVs have different levels of overscan — so testing your app in a few models might not be enough, and there’s currently no way for tvOS to query them for the amount of overscan being used. So the safest route you can go is using industry standards to account for that. <a href="https://developer.apple.com/tvos/human-interface-guidelines/visual-design/">Apple recommends placing your layout in a box that sits 90 pixels from side edges and 60 pixels from top and bottom edges</a>.</p><p><em>So if we were only allowed to take one lesson from the whole project, this would probably be it: account for overscan, and do so right at the beginning.</em> It won’t be fun gathering everyone around to show your fresh new app only to find out the aggressive overscan on the TV breaks your layout. It also won’t be fun refactoring a potentially massive storyboard, if you went with that option.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*igw7r8zsUsyFJZoyzaPvQQ.jpeg" /><figcaption>How Revert could look without thinking about overscan, ouch!</figcaption></figure><p><em>As mentioned in the beginning of this post, Revert helps us optimize and improve Reveal in every update. So if you are a Reveal user (thanks! 🎉) and find yourself with an example that doesn’t work quite right, please </em><a href="https://github.com/revealapp/Revert"><em>fork Revert on GitHub</em></a><em> and submit us a pull request with your edge case so we can make Reveal even more useful to you in the future!</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*0Mh71vxN8GTbmeukTU2MRw.png" /></figure><p><em>Based in Melbourne, Australia, </em><a href="http://ittybittyapps.com/"><strong><em>Itty Bitty Apps</em></strong></a><em> builds great software on mobile and Mac for clients big and small. It also makes </em><a href="https://revealapp.com/"><strong><em>Reveal</em></strong></a><strong><em> </em></strong><em>— Amazingly powerful runtime view debugging for iOS developers.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ca2c2867fd1c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/itty-bitty-apps/taking-revert-to-tvos-ca2c2867fd1c">Taking Revert to tvOS</a> was originally published in <a href="https://medium.com/itty-bitty-apps">Itty Bitty Apps</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Looking for some great people]]></title>
            <link>https://medium.com/itty-bitty-apps/looking-for-some-great-people-e353ed787d17?source=rss----4b4f26e2e28e---4</link>
            <guid isPermaLink="false">https://medium.com/p/e353ed787d17</guid>
            <category><![CDATA[jobs]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[greatness]]></category>
            <dc:creator><![CDATA[Baz Scott]]></dc:creator>
            <pubDate>Tue, 27 Sep 2016 00:00:02 GMT</pubDate>
            <atom:updated>2016-09-27T00:00:02.066Z</atom:updated>
            <content:encoded><![CDATA[<p>As far as we’re concerned, greatness is everything. In the way we work, in the way we treat each other, and most of all, in the products we create.</p><p>Greatness is in the standards we set for ourselves. We don’t just strive for great ideas — we bring them to life as great, useful things. We push ourselves to dig deeper for solutions, asking ‘how can this be better?’ — greater — even when it’s already good.</p><p>And now we are looking for a few great people to join us in solving problems for a wide variety of interesting clients, and to work on our own products.</p><p>We’re not going to list a bunch of skills and years of experience you need in order to work with us — we have people with a wide variety of skills and experiences in our team and we want more of that — in fact that’s what makes a great team.</p><p>In broad terms if you are excelling in the field of native mobile (or Mac) apps — as a Designer, iOS Developer, Android Developer, or Mac Developer — we want to talk to you.</p><p>You will need skills of course, but there are certain general qualities that are as important as specific skills or experience. Here are some of them:</p><p><strong>You work great in a team.</strong> Collaboration and shared understanding are critical to working effectively in our teams and delivering great products with our clients. You’ll get to work in a wide variety of companies and teams, so adaptability is a key skill.</p><p><strong>You solve problems.</strong> We are a problem solving company — you could say that’s basically all we do. We try to think of the why before the how and dig deep to create the very best solutions we can, within the constraints of a project.</p><p><strong>You work well with clients.</strong> Working with clients is stimulating, challenging, and hugely rewarding – but it’s not always easy. Clients are naturally concerned about where their time and money is going, and every project has it’s own challenges and quirks. Adaptability is key — circumstances will change, and that’s exciting!</p><p><strong>You are a listener.</strong> If we don’t listen, really listen, to our clients and each other we can’t answer the right questions or propose the right solutions. We value people who can really listen to others and take other points of view on board – then build on them.</p><p><strong>You are a great communicator.</strong> Working with clients and internal teams involves a lot of communication, in written form and mostly verbally. You need to be comfortable in getting your ideas across to clients well.</p><p>If this describes you and entices you please get in touch at <a href="/service/mailto:jobs@ittybittyapps.com">jobs@ittybittyapps.com</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e353ed787d17" width="1" height="1" alt=""><hr><p><a href="https://medium.com/itty-bitty-apps/looking-for-some-great-people-e353ed787d17">Looking for some great people</a> was originally published in <a href="https://medium.com/itty-bitty-apps">Itty Bitty Apps</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Scripting LLDB with Python]]></title>
            <link>https://medium.com/itty-bitty-apps/scripting-lldb-with-python-31718eb4e501?source=rss----4b4f26e2e28e---4</link>
            <guid isPermaLink="false">https://medium.com/p/31718eb4e501</guid>
            <category><![CDATA[lldb]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[debugging]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Josh Kugelmann]]></dc:creator>
            <pubDate>Fri, 22 Jul 2016 04:27:30 GMT</pubDate>
            <atom:updated>2016-07-22T04:27:30.189Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-ntKLqqHYGrRsFoT1xgrJw.jpeg" /></figure><p>One of the more obscure features of LLDB is its ability to be scripted using Python. LLDB includes Python bindings to its C++ API (LLDB.Framework/liblldb).</p><p>These can be used in two ways:</p><ul><li>From within LLDB itself to provide extended functionality such as adding custom commands or performing more complex operations.</li><li>As a standalone library used outside LLDB to create anything from fully automated debug sessions, to new debugger front-ends.</li></ul><p>In this post, I’m going to show you how extending LLDB can allow you to reduce a string of repetitive commands into a single action, and expose a whole new level of power that you can use to improve your debugging productivity.</p><h3>Adding Commands</h3><p>The most simple, and arguably the most common use of the scripting functionality, is to add customised commands to use from within the debugger interface.</p><p>For this example, we’re going to create a custom command that returns the bundle identifier of the application being debugged.</p><p>Custom commands can be added using the <em>command script add</em> command. For example:</p><pre>command script add -h &quot;Returns the bundle identifier of the application being debugged.&quot; -f iba_lldb.GetBundleIdentifier bundle_id</pre><p>Would add a command named <em>bundle_id</em>, bound to the function <em>GetBundleIdentifier</em> in the <em>iba_lldb</em> module.</p><p><em>command script add</em> takes the following arguments:</p><ul><li><em>(Optional) </em><strong>-f:</strong> The first specifies the name of the Python function that the command should be bound to. This is in the format <em>{module name}.{function name}</em>.<br> <br>In Python, a module is just a <em>.py</em> file containing Python code. So if your script was named <em>iba_lldb.py</em>, the module name would be <em>iba_lldb</em>.<br> <br>If this option is not specified, LLDB will prompt you to enter your Python code in the debugger itself.</li><li><em>(Optional) </em><strong>-h:</strong> Specifies the help text for the command displayed when the user types <em>help {command name}</em></li><li><em>(Required)</em>:<em> </em>The last (unnamed) argument specifies the name of the command as used in LLDB<em>.</em></li></ul><h4>Creating a Command Handler</h4><p>So how do we define command handler functions? In your Python script, first make sure to import the <em>lldb</em> module:</p><pre>import lldb</pre><p>Command handlers must take 4 parameters:</p><ol><li><strong><em>debugger</em>:</strong> An <em>SBDebugger</em> object.</li><li><strong><em>command</em>:</strong> A string containing all of the arguments passed to your command. This string can be parsed into a list of options using the standard <em>shlex</em> and <em>optparse</em> modules.</li><li><strong><em>result</em>:</strong> An <em>SBCommandReturnObject</em> that can be used to provide a status and return value for the command.</li><li><strong><em>internal_dict</em>:</strong> A dictionary containing the variables and functions that are available in the scripting session. As its name suggests, it is for internal use only.</li></ol><p>Following on with our example command, the function body ends up looking like this:</p><pre>def GetBundleIdentifier(debugger, command, result, internal_dict):<br>    target = debugger.GetSelectedTarget()<br>    process = target.GetProcess()<br>    mainThread = process.GetThreadAtIndex(0)<br>    currentFrame = mainThread.GetSelectedFrame()</pre><pre>    bundleIdentifier = currentFrame.EvaluateExpression(&quot;(NSString *)[[NSBundle mainBundle] bundleIdentifier]&quot;).GetObjectDescription()</pre><pre>    result.AppendMessage(bundleIdentifier)</pre><p>Executing our custom command in the console gives us exactly what we’d expect:</p><pre><strong>(lldb)</strong> bundle_id<strong><br></strong>com.ittybittyapps.revert</pre><p>While not the most useful command, it does serve as a good demonstration of how to use the LLDB APIs.</p><h3>Custom Type Summaries</h3><p>Another powerful feature that LLDB allows through its scripting functionality is the ability to add customised summaries for non-standard data-types.</p><p>Say we have a hypothetical struct <em>IBARange:</em></p><pre>typedef struct IBARange {<br>    int startIndex;<br>    int endIndex;<br>} IBARange;</pre><p>By default, printing a variable of type <em>IBARange</em> using the <em>print</em> command will give the following:</p><pre>(IBARange) $1 = (startIndex = 42, endIndex = 100)</pre><p>While printing using the <em>po</em> command gives us nothing at all!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*g8gsklvOPbFzbchT2fazfQ.png" /></figure><p>If we wanted to find out the length of this range, we could do something like this:</p><pre>print range.endIndex - range.startIndex</pre><p>But why do this every time, when we can have the debugger do the work for us? In a similar fashion to adding commands, we can use the <em>type summary add</em> command to instruct LLDB to use a custom summary that displays the start index, end index <em>and</em> the length of our <em>IBARange</em> struct<em>:</em></p><pre>type summary add -F <em>iba_lldb</em>.IBARangeSummary IBARange</pre><p>Your type summary handler function should take two arguments:</p><ul><li><strong><em>value</em>: </strong>An <em>SBValue</em> object representing the value of the variable in question.</li><li><strong><em>internal_dict</em>: </strong>A dictionary containing the variables and functions that are available in the scripting session. As its name suggests, it is for internal use only.</li></ul><p>Following on from above, we can now add a type summary handler named <em>IBARangeSummary</em> in <em>iba_lldb.py</em> like so:</p><pre>def IBARangeSummary(value, internal_dict):<br>    start = value.GetChildMemberWithName(&quot;startIndex&quot;).GetValueAsSigned()<br>    end = value.GetChildMemberWithName(&quot;endIndex&quot;).GetValueAsSigned()<br>    length = end - start</pre><pre>    return &quot;(start = {0}, end = {1}, length = {2})&quot;.format(start, end, length)</pre><p>Now when we print a variable of the <em>IBARange</em> type, we get:</p><pre>(IBARange) $2 = (start = 42, end = 100, length = 58)</pre><p>Much better!</p><p>As an added bonus, our summary will also be used for pointers pointing to instances of <em>IBARange</em>. Before adding our custom summary, printing a pointer to an <em>IBARange</em> would yield the following, for example:</p><pre>(IBARange *) $3 = 0x00007fff51c2ae18</pre><p>With our custom summary, we get much nicer results:</p><pre>(IBARange *) $4 = (start = 42, end = 100, length = 58)</pre><h3>Finishing Touches</h3><p>When your script is loaded by LLDB, it will call the <em>__lldb_init_module</em> function. From here, we can perform any needed setup, such as adding our commands and type summaries.</p><p>This cannot be done purely with the Python API, as no targets are defined at the stage <em>__lldb_init_module</em> is called. Instead, we have to ask LLDB to execute the appropriate commands for us:</p><pre>def __lldb_init_module(debugger, internal_dict):<br>    debugger.HandleCommand(&quot;command script add -f &quot; + __name__ + &quot;.GetBundleIdentifier bundle_id&quot;)<br>    debugger.HandleCommand(&quot;summary type add -F &quot; + __name__ + &quot;.IBARangeSummary IBARange&quot;)</pre><p>Here, we fetch the module name dynamically using the <em>__name__</em> variable. This means that you won’t need to update your script every time you change its file name.</p><p>If you want your commands to be available in every LLDB session, you can import the script in your <em>~/.lldbinit</em> file, as follows (assuming <em>iba_lldb.py</em> is in your home directory):</p><pre>command script import <em>iba_lldb</em>.py</pre><p>If you’re using Xcode and only want your commands to be available from inside there, you can import the script in your <em>~/.lldbinit-Xcode</em>. This file is read by Xcode whenever a debug session is started, but not by regular LLDB builds.</p><h3>References</h3><p>Some rudimentary documentation for the Python API is available <a href="http://lldb.llvm.org/python_reference/index.html">here</a>. The <a href="http://lldb.llvm.org/cpp_reference/html/index.html">C++ reference</a> may also be helpful, as the API translates pretty much 1:1 across both languages.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qtwi6-ZnEe2_i-bdd1ImOA.png" /></figure><p><em>Based in Melbourne, Australia, </em><a href="http://ittybittyapps.com/"><strong><em>Itty Bitty Apps</em></strong></a><em> builds great software on mobile and Mac for clients big and small. It also makes </em><a href="https://revealapp.com/"><strong><em>Reveal</em></strong></a><strong><em> </em></strong><em>— Amazingly powerful runtime view debugging for iOS developers.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=31718eb4e501" width="1" height="1" alt=""><hr><p><a href="https://medium.com/itty-bitty-apps/scripting-lldb-with-python-31718eb4e501">Scripting LLDB with Python</a> was originally published in <a href="https://medium.com/itty-bitty-apps">Itty Bitty Apps</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Is iOS first development the right strategy?]]></title>
            <link>https://medium.com/itty-bitty-apps/is-ios-first-development-the-right-strategy-fe7ad472856e?source=rss----4b4f26e2e28e---4</link>
            <guid isPermaLink="false">https://medium.com/p/fe7ad472856e</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[mobile]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Cassie Wilson]]></dc:creator>
            <pubDate>Fri, 01 Jul 2016 05:48:37 GMT</pubDate>
            <atom:updated>2016-07-06T04:01:37.565Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fKkOsiUBTvx9QMQ_Eg72bg.jpeg" /></figure><p>Within the application development community in Australia there has been a long held belief that the majority of mobile users in Australia are using iOS. Many clients will typically focus on an iOS version of their application based on this assumption. This results in much of the design and testing effort disproportionally favouring iOS over Android. The common refrain goes “Our users will be mostly on iOS so let’s focus on them.” Surprisingly this might not actually be the case.</p><h4>What do the numbers say?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/912/1*Q446j51XaWlZ3oajh4fd_Q.png" /><figcaption>Percentage Market Share of Smart Phone Sales for Australia [1]</figcaption></figure><p>From the graph it is obvious that Android has been consistently capturing a larger percentage of new phone sales. In fact the only time that iOS has outsold Android in the last 4 years has been for a two month period when the iPhone 6 was release in 2014.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/182/1*O3zFOSjSJeXB49vyXwXXLQ.png" /><figcaption>% Market Share of Sales for USA 3 M/E April 2016 [1]</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/182/1*qt7LSClJ7D4c9GNt1fjvFg.png" /><figcaption>% Market Share of Sales for Spain 3 M/E April 2016 [1]</figcaption></figure><p>The above data is looking just at Australia, however these sort of numbers can be compared to other western markets such as the US or UK. The difference between iOS and Android is even more pronounced in some parts of the world. For example Spain’s sales are heavily dominated by Android smartphones.</p><h4>What does this mean?</h4><p>From the market share data alone we cannot reach any strong conclusions relating to primary platform selection. However luckily we also have some data around the number of downloads and revenue for each platform.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/411/1*sQG1LLSY_xEzb34p7v-l7g.png" /><figcaption>App Annie Indexed Downloads Q1 2016 [2]</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/409/1*DTi1Vg87GXwO0W7olRLdPw.png" /><figcaption>App Annie Indexed Revenue Q1 2016 [2]</figcaption></figure><p>Taking these three graphs together we start to see a more complete picture. There is a larger number of Android devices. Which leads to a larger number of App downloads on Android. However users in the iOS ecosystem are more willing to spend money through the App store.</p><p>The ideal for developing a new Application is to develop for both platforms at once, and releasing simultaneously. However if you have limited budget, or want to roll out more slowly we can reach a rudimentary strategy based on these graphs:</p><ul><li>If you are a service or subscription based application looking to reach the largest number of users to get them into your ecosystem, then going with an Android first approach might be the way to go.</li><li>However if you are a paid application, or rely on in app revenue as your main revenue stream, then an iOS first approach is likely better for you.</li></ul><p>Choosing a strategy gets more complicated when you take into account things like:</p><ul><li>Current user base: if you have a web offering, which platforms are you seeing the most traffic/conversions from?</li><li>Target market: do you have demographic data that could give you an indication as to which platform your target market predominantly use?</li><li>Launch strategy: do you want to soft launch to a smaller market and iterate? Or hit the market with a fanfare? etc.</li><li>Use cases for your application: are you relying on platform specific technologies (Apple Pay, NFC, etc.)?</li><li>And so many more!</li></ul><h4>Is an iOS first development strategy right for your app?</h4><p>That’s where specific research and industry knowledge comes into play. Each application and organisation is different and needs the love and attention of professional research and planning. Coarse statistics like those shown in the graphs above can be useful for general trends but it is the more specific data where the true insights can be found. Always do your research!</p><h4>Appendix</h4><p>[1] <a href="http://www.kantarworldpanel.com/global/smartphone-os-market-share/">http://www.kantarworldpanel.com/global/smartphone-os-market-share/</a></p><p>[2] <a href="http://files.appannie.com.s3.amazonaws.com/reports/App-Annie-Index-Market-Q1-2016-EN.pdf">http://files.appannie.com.s3.amazonaws.com/reports/App-Annie-Index-Market-Q1-2016-EN.pdf</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qtwi6-ZnEe2_i-bdd1ImOA.png" /></figure><p><em>Based in Melbourne, Australia, </em><a href="http://ittybittyapps.com/"><strong><em>Itty Bitty Apps</em></strong></a><em> builds great software on mobile and Mac for clients big and small. It also makes </em><a href="https://revealapp.com/"><strong><em>Reveal</em></strong></a><strong><em> </em></strong><em>— Amazingly powerful runtime view debugging for iOS developers.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fe7ad472856e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/itty-bitty-apps/is-ios-first-development-the-right-strategy-fe7ad472856e">Is iOS first development the right strategy?</a> was originally published in <a href="https://medium.com/itty-bitty-apps">Itty Bitty Apps</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[When is the right time to adopt Swift 3?]]></title>
            <link>https://medium.com/itty-bitty-apps/when-is-the-right-time-to-adopt-swift-3-73604a348047?source=rss----4b4f26e2e28e---4</link>
            <guid isPermaLink="false">https://medium.com/p/73604a348047</guid>
            <category><![CDATA[cocoa]]></category>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[opinion]]></category>
            <category><![CDATA[swift]]></category>
            <dc:creator><![CDATA[Oliver Jones]]></dc:creator>
            <pubDate>Sun, 26 Jun 2016 06:07:36 GMT</pubDate>
            <atom:updated>2016-07-04T04:25:26.840Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aKS-gxGhJzLlxyWpc6NMgw.png" /></figure><p>It has been two years since Apple introduced Swift.</p><p>In the first 12 months I was quite hesitant to recommend Swift as an implementation language. In fact I think my exact words were “hell no”. The tools were not stable and the language and libraries were quite immature during Swift’s freshman year.</p><p>However, in the last 12 months the language has been going from strength to strength. Apple open sourced Swift and opened up the evolution of the language to the broader community through <a href="http://swift.org/">Swift.org</a>.</p><p>This has encouraged a wealth of community contributions to Swift through the <a href="https://swift.org/contributing/#participating-in-the-swift-evolution-process">Swift Evolution Process</a> and the upcoming release of Swift 3 bears fruit from these efforts. Swift 3 brings with it the most significant changes the language has seen in its short lifetime.</p><h3>Swift 3 and “The Great Renaming”</h3><p>Probably the most significant change coming with Swift 3 is “The Great Renaming”.</p><p>During this last year the Swift Evolution Process has produced a number of <a href="https://github.com/apple/swift-evolution">proposals</a> to clarify and standardise the naming scheme for the Swift Standard Library and how Swift imports Apple’s existing frameworks like Foundation, UIKit and Core Graphics. This has yielded the “<a href="https://developer.apple.com/videos/play/wwdc2016/403/">Swift API Design Guidelines”</a>.</p><p>This new naming standard means Swift 3 will be quite different from Swift 2 when working with these frameworks. With the move to Swift 3, nearly all existing Swift code will need to be migrated to the new naming standard and follow these guidelines.</p><p>Xcode 8 includes a migration tool to help with this transition. Tools are great but as is the case with most tools it is there to save you work, not remove all thought from the process. I’m of the opinion that all Swift application code will still need to be audited and reviewed by a human post migration. In addition, the migration tool can’t help you transition your existing application code to the new API guidelines. It only addresses how your code interacts with Apple’s frameworks and how that API has changed.</p><h3>Swift 3 and ABI stability</h3><p>One of the goals for Swift 3 was ABI stability. <a href="http://ericasadun.com/2016/05/16/winding-down-swift-3-0-abi-stability-deferred/">This didn’t happen</a>. What this means is that in order to upgrade a project to Swift 3 all the Swift dependencies of that project also need to be updated to Swift 3. It is not possible to link a Swift 3 application with Swift 2 libraries.</p><p>ABI stability will most likely come to Swift 3 sometime in the next 12 months and <a href="https://developer.apple.com/videos/play/wwdc2016/402/">at WWDC this year Chris Lattner</a> stated that maintaining source compatibility will be a strong constraint when considering changes to the language going forward. So hopefully there will be no need for a “Great Renaming 2” next year.</p><h3>When to Switch to Swift 3?</h3><p>Teams should start planning for this now. Depending on the scale of an existing Swift codebase this migration could have a significant impact on a project. All of a project’s dependencies will also need to have adopted Swift 3 before the main application can adopt Swift 3. Libraries adopting Swift 3 and migrating to the new API Guidelines will likely change their own APIs as a result. This will mean a lot of uses of library code in an application will need to be changed. Something the Xcode 8 migration tool can’t help with.</p><p>To ease with the adoption of Swift 3, developers should become familiar with the new <a href="https://swift.org/documentation/api-design-guidelines/">API Design Guidelines</a> and begin adopting them in new code as of today.</p><p>If you have an existing Objective-C codebase, and you’ve not yet started adopting Swift, then you may want to hold off adopting Swift until version 3 ships later in the year. This will put you in a better position than adopting Swift 2.x at this late stage and then having to go through the migration process.</p><p>Adopting Swift 3 right now, while it is in preview/beta, will be a painful process as very little 3rd party library code is ready yet. Although this will likely change rapidly during the Xcode 8 and iOS 10 beta period.</p><p>Fortunately, for developers who want to take a slow and steady approach to Swift 3 adoption, Apple have introduced features into Xcode 8 to allow developers to continue to use Swift 2 beyond the release of iOS 10. Xcode 8 supports both Swift 2.3 and 3. You can not mix them together in a single application but you can continue to use 2.3 until it is convenient for your project and team to make the Switch to 3.</p><h3>Is Swift the future of Cocoa development?</h3><p>Short answer: Yes.</p><p>I’ve always thought that a tipping point for Swift adoption would be when Apple themselves started introducing frameworks that were Swift only. While Apple has yet to go that far, they are <a href="https://developer.apple.com/videos/play/wwdc2016/207/">starting to introduce Swift only features to some of the foundation frameworks</a> upon which everything is built. Changes that make working with these frameworks feel much more native to the Swift language. These additions, and Apple’s introduction of <a href="https://developer.apple.com/swift/playgrounds/">Swift Playgrounds for iOS</a> as an educational aid speak to Apple’s commitment to push further toward a Swift only future.</p><p>It may be many years before Objective-C takes its final bows and exits the Cocoa development scene but on balance I think the advantages of Swift are quickly becoming apparent. If you’ve yet to jump on board the Swift bandwagon, the upcoming transition to Swift 3 might present the right opportunity to do so.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qtwi6-ZnEe2_i-bdd1ImOA.png" /></figure><p><em>Based in Melbourne, Australia, </em><a href="http://ittybittyapps.com/"><strong><em>Itty Bitty Apps</em></strong></a><em> builds great software on mobile and Mac for clients big and small. It also makes </em><a href="https://revealapp.com/"><strong><em>Reveal</em></strong></a><strong><em> </em></strong><em>— Amazingly powerful runtime view debugging for iOS developers.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=73604a348047" width="1" height="1" alt=""><hr><p><a href="https://medium.com/itty-bitty-apps/when-is-the-right-time-to-adopt-swift-3-73604a348047">When is the right time to adopt Swift 3?</a> was originally published in <a href="https://medium.com/itty-bitty-apps">Itty Bitty Apps</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>