<?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 Graham Wood on Medium]]></title>
        <description><![CDATA[Stories by Graham Wood on Medium]]></description>
        <link>https://medium.com/@grahamwood_10408?source=rss-ff2f4d638e65------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*PNRQh8_jM1hA0386.</url>
            <title>Stories by Graham Wood on Medium</title>
            <link>https://medium.com/@grahamwood_10408?source=rss-ff2f4d638e65------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 16 Nov 2026 23:55:20 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@grahamwood_10408/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[Code Sharing: A recipe for how we quickly cooked up the Tasty app]]></title>
            <link>https://medium.com/buzzfeed-tech/code-sharing-a-recipe-for-how-we-quickly-cooked-up-the-tasty-app-55e7bcb1e1eb?source=rss-ff2f4d638e65------2</link>
            <guid isPermaLink="false">https://medium.com/p/55e7bcb1e1eb</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[buzzfeed-posts]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Graham Wood]]></dc:creator>
            <pubDate>Wed, 11 Apr 2018 18:05:43 GMT</pubDate>
            <atom:updated>2018-04-11T18:05:43.341Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/340/1*ff4UTdAuZnnFUNBtupJnLA.gif" /></figure><h4>The journey to the mono repo</h4><p>There was a time when there was one gigantic Xcode project that housed all of the functionality that you see in the BuzzFeed app. This made it a “clone and own” job to create another app that may want to share a lot of the same business logic. The advantages of cloning and owning an existing app is that it enables you to start with a complete set of functionality that can be easily tailored to your requirements, and you don’t have to worry about maintaining compatibility when making changes to existing code. The disadvantages of this approach are that any bugs found need to be fixed in multiple places, and new features that may benefit both apps are built independently. This would be a good approach if the short term goal to get an app to market outweighs the benefit of shared code, but in our case we need to be able to maintain and build upon each app continuously.</p><p>The BuzzFeed News and BuzzFeed Video apps had to take this approach for two reasons: Swift was new and because the existing BuzzFeed iOS app was largely written in Objective-C. These new apps were built with common frameworks embedded in their projects using Carthage. The BuzzFeed iOS app also started using this framework approach to share code across targets. For example, the BuzzFeed iOS app for iPhone/iPad and tvOS app for Apple TV share the same video player code. This solved the problem of duplicate copies of code, improving our process, but it didn’t quite get us to a mono repo.</p><p>Here is a timeline of our iOS git repo history:</p><ul><li><strong>Early 2010:</strong> The initial iOS git repo was started with the BuzzFeed app Xcode project</li><li><strong>Fall 2012: </strong>Hurricane Sandy takes out our data center and iOS repo, and a github repo was created from the repo with the latest pull from master (yay for distributed version control!)</li><li><strong>Early 2015:</strong> The team started working on BuzzFeed News and BuzzFeed Video Apps in Swift (before primarily in Objective-C) in separate repos.</li><li><strong>Mid 2015</strong>: The BuzzFeed app dropped iOS 7 support and started making common code in Swift frameworks.</li><li><strong>Mid 2015 to Early 2016</strong>: There was continued effort to move common code from apps over to frameworks. Any new code that had the possibility of being shared was developed in frameworks.</li><li><strong>April 2016:</strong> The iOS mono repo was created.</li><li><strong>Early 2017:</strong> The Tasty app was created in the mono repo.</li><li><strong>July 2017:</strong> The Tasty iOS app was launched on the App Store.</li></ul><h4>Challenges faced before moving to a mono repo</h4><p>Updating code in shared frameworks contained in different repositories is a mundane task. Debugging apps in separate repositories requires extra work, too. Once a framework is updated and ready for release, it must be versioned and tagged. At that point any dependent frameworks and apps must make sure to pull in the updated version in order to stay current with the latest update, which could contain an important bug fix. This can be less obvious if the update happens down the dependency chain. If the build system is not set up to automatically pull in all updated frameworks, this process is quite prone to human error. For example: Framework A is dependent on Framework B, and Framework B is dependent on Framework C. If the app only has a direct dependency on A, you would <em>not</em> get the update for a fix in C unless B <em>and </em>A have pulled in the update to C.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/291/1*i6KCnUhFH3X9Hi0whPX0aw.gif" /><figcaption>Trying to manage framework dependencies</figcaption></figure><h4>Enter the mono repo</h4><p>Our web services at BuzzFeed transitioned to <a href="https://tech.buzzfeed.com/deploy-with-haste-the-story-of-rig-ca9a58b5719a">using rig with a mono repo</a>. While the apps teams don’t have the need to deploy continuously, we thought the use of a single git repo for all of our iOS apps would alleviate some of the issues that we were having. The mono repo at BuzzFeed does not consist of all of our code across the organization. While discussions have happened on the pros and cons of that approach, we felt it best to keep our mobile application repos separate from our web service mono repo, so we created our own apps mono repo!</p><p>The only drawbacks we foresaw with an iOS mono repo were larger build times and less ability to plan for updates (if one app updates a framework, others have to use that or branch). Since changes to shared frameworks are immediately built in all apps, it was a bit more effort up front to implement good test coverage to ensure that nothing breaks when a framework is updated. These cons have been fairly painless and have definitely been outweighed by the pros of having the mono repo organization in place.</p><h4>Types of shared frameworks</h4><p>We utilize common code for the following things across apps/targets in our mono repo:</p><ul><li>Common UIKit and Foundation extensions/utilities and theming</li><li>A/B testing framework</li><li>Playing video</li><li>Collection view helpers</li><li>Common models</li><li>Handling network requests</li><li>Sharing activities</li><li>Analytics</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/450/1*kEB9Pm9YPcsLttzG5soHEg.gif" /></figure><h4>The Tasty app</h4><p>When the plan came along to build a Tasty app, we needed to make a decision on whether we should spin up a new repo with copies of our frameworks to be maintained separately, or learn to work in the mono repo. It was an easy decision to use the mono repo for many reasons. It had been had been in use for nearly a year and the build and automated test system was already well established. During the time that the Tasty app was to be developed there would have been many changes in the shared frameworks that would have been either missed by Tasty or had to have been manually pulled into Tasty’s repo. The only lifting that was needed to get a Tasty app up and running with our shared frameworks was mapping the Tasty data models to work with our collection view rendering framework (the framework that takes article or recipe JSON from our API and displays it in a UICollectionView) and tweaking the layout code to match our design.</p><p>You might think that collection view rendering is simple enough: this isn’t that big of a savings in effort versus building from scratch; however, our collection view rendering framework handles all different types of cells (the basic UI component of a collection view). Some example of cells the framework can render are autoplaying video cells and horizontally scrolling carousels of content (recipes in our case, breaking news stories in the case of the BuzzFeed app). With these cells also comes any impression and interaction analytics that we can use to determine what content and features are most successful.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VhrW2V9C91PS2HNk." /><figcaption>Here are side by side views of the BuzzFeed (left) and Tasty (right) app collection views, which share a common rendering framework.</figcaption></figure><p>This allowed us to focus immediately on building our new app features, specifically the recipe page and the step by step instruction flow. We were able to use some common framework code here and even contribute back to it.</p><h4>Day to day pains of shared frameworks in a mono repo</h4><p>Every architectural decision is visited with the question of whether the code should live in a common framework in each app’s specific code base. There is a lot of clone and owned code that does not make sense to put in a common framework (or at least didn’t for the Tasty iOS team), such as our deep linking logic and utilities for navigation to different areas of the app.</p><p>Any code change in a common framework must be regression tested on BuzzFeed <em>and</em> Tasty apps and must not break any of our tests. Our engineers have had to make a habit of building and running multiple configurations (BuzzFeed app, Tasty app, test targets for each app, and test targets for any common framework changed) before pushing these changes up to github and having the build server find they broke the build for another target. Since the build server takes a long time to build all of the targets, bugs and regressions aren’t usually discovered for some time, and usually this results in variations of the following gif being posted to our slack channel:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/270/0*GxubLo3bQO2y-bMX." /></figure><p>This has just moved the work to the developer of the breaking change, where previously the impact of the change would likely not be known until another app or framework tries to update to the new version of the framework.</p><p>Swift migrations and Xcode updates have been painful, because everyone must agree on a plan so that we can move all of our code over at the same time.We also all share some of the effort of updating our common code base. As time goes on and Swift matures these migrations have been less painful, especially since frameworks have been allowed to build with different Swift versions.</p><h4>Where are we now?</h4><p>The Tasty app has been live in the App Store for almost nine months. As we add new features, we continue to explore opportunities for adding shared code and reducing tech debt in our common frameworks. Our iOS engineers meet weekly to discuss any common work that is in progress or coming up in near sprints so that we can coordinate these changes. We’ve discovered that some of our day to day pains can be used to our advantage. If we need to staff up an app for a sprint/release or two to crank out a feature, it is much easier to do so given their understanding of the common code base. Our transition to XCode 9 was smooth: we could all update as soon as our changes were merged into our master branch, thus putting behind us the pain of coordinating the update across all of the frameworks and repos. We don’t have surprises during regression testing from integrating a version of a framework that we neglected to pull in updates for. While it can be painful doing more testing on each feature, the benefits far outweigh the pains, and we’ve got a much stronger shared code base that we can more easily base new features off of!</p><p><em>To keep in touch with us here and find out what’s going on at BuzzFeed Tech, be sure to follow us on </em><a href="http://twitter.com/buzzfeedexp"><em>Twitter @BuzzFeedExp</em></a><em> where a member of our Tech team takes over the handle for a week!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=55e7bcb1e1eb" width="1" height="1" alt=""><hr><p><a href="https://medium.com/buzzfeed-tech/code-sharing-a-recipe-for-how-we-quickly-cooked-up-the-tasty-app-55e7bcb1e1eb">Code Sharing: A recipe for how we quickly cooked up the Tasty app</a> was originally published in <a href="https://medium.com/buzzfeed-tech">BuzzFeed Tech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>