<?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 Erica Engle on Medium]]></title>
        <description><![CDATA[Stories by Erica Engle on Medium]]></description>
        <link>https://medium.com/@ericaengle?source=rss-e47f010fbeae------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*RdkUVD72XaO_3zvO50IZ3Q.png</url>
            <title>Stories by Erica Engle on Medium</title>
            <link>https://medium.com/@ericaengle?source=rss-e47f010fbeae------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 04:09:14 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ericaengle/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[5 Tips for Developers New to SwiftUI]]></title>
            <link>https://medium.com/@ericaengle/5-tips-for-developers-new-to-swiftui-5acaf20798bf?source=rss-e47f010fbeae------2</link>
            <guid isPermaLink="false">https://medium.com/p/5acaf20798bf</guid>
            <category><![CDATA[swiftui]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[mobile]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Erica Engle]]></dc:creator>
            <pubDate>Mon, 13 Mar 2023 21:38:19 GMT</pubDate>
            <atom:updated>2023-03-13T21:38:19.618Z</atom:updated>
            <content:encoded><![CDATA[<p><em>For new engineers who want to up their iOS and Mac app development game, check out these 5 tips for using SwiftUI.</em></p><p>SwiftUI is Apple’s latest UI development tool. Unlike UIKit or AppKit, SwiftUI provides developers with a more straightforward method of building iOS or Mac apps. Using the swift language and declarative syntax, SwiftUI lets developers:</p><ul><li>Build with speed given the ease of access to modifiers</li><li>Focus on creating well laid out views without relying on AutoLayout constraints</li><li>Iterate with confidence given the straightforward relationship from code to visible product</li><li>Only change components that specifically need to be reloaded through observers or other state changes</li></ul><p>There’s a lot to learn while developing on the fly. Here are five tips for getting started with SwiftUI in no time.</p><ol><li>Order Matters</li></ol><p>Building apps with SwiftUI is a lot like building with LEGOs to create one shiny interface for users. Stack your LEGO bricks as intended to see the structures you desire. And similarly with your app, you want a rectangle with slightly less sharp corners? Add a .cornerRadius(_) modifier to your Rectangle() and it will now have slightly rounded edges.</p><p>Here’s where things get interesting: (1) try creating a Text() view object and adding padding; then try adding a border modifier and (2) then another Text() object with a border then padding and you will get two entirely different results.</p><p>The first would look something like:</p><pre>Text(&quot;Hello, world!&quot;)<br>    .padding(10)<br>    .border(Color.red)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/246/1*SuqYYX-GUiTN4QGsqRhksA.png" /></figure><p>And the second:</p><pre>Text(&quot;Hello, moon!&quot;)<br>    .border(Color.red)<br>    .padding(10)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/208/1*1CQxZlSrUw8pIiIHliQfHA.png" /></figure><p>In the first, the border is pushed out 10 pixels because of the padding and in the second, the border is hugging the text (padding on the outside where you can’t see). Meticulous ordering applies to all view modifiers. Make sure to consider the order in which to apply modifiers when debugging. If you see some random “space” you didn’t expect to see or just want to apply modifiers to get the UI you want, remember this tip about order.</p><p>As a bonus, it’ll be nice to clearly communicate your intent for the next person who might be looking at your code!</p><p>2. Spacial Awareness</p><p>Not all views are laid out equally in SwiftUI, which makes spacing different across view types. Think of LEGO vs DUPLO for example: the building blocks come in different sizes, each catered towards the age range of their users. A DUPLO block will work in a structure that could normally use LEGOs, but will look differently to the user at the end of construction. Take a moment to think about the view you’re building and what view you’ll be using so you can assess what space it will take up.</p><p>Take a Text() view and a Rectangle() view for example:</p><pre>Text(&quot;Hello, world!&quot;)<br>    .border(Color.red)<br>Rectangle()<br>    .border(Color.red)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/288/1*RckGEQ8LATh04A4H_tEVkg.png" /></figure><p>As we can see, the Text() view doesn’t fill space like the Rectangle() does. This means if we make a Rectangle and add text to it, it will interpret space in the UI differently than the Text view. This applies to other types of views as well, so taking a moment to think about the high level view of your UI and then picking the components will save you some time down the line.</p><p>Most shapes can be fairly unpredictable when laid out, much the same as a LEGO when attached to another LEGO can take up a wider space than the LEGO below it. We can be more deterministic about a shape filling its space with the application of static or dynamic dimensions. It can also help with readability as well if another developer can see dimensions typed out.</p><p>Rectangle with static dimensions set:</p><pre>Rectangle()<br> .frame(width:100, height: 100, alignment: .center)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/288/1*cNcJzpgm0ZJd0JzZ4NAP7A.png" /></figure><p>Rectangle with dynamic dimensions set:</p><pre>Rectangle()<br>    .frame(maxWidth: .infinity)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/288/1*5JV55DXgU_un_CeET6mpIg.png" /></figure><p>3. Reusable Components</p><p>It’s pretty easy to lose things in files, especially as a project grows considerably. If you’re repeatedly designing similar screens, reusable components will become a critical part of the process. They save time, ensure consistency in the app, and let you focus on more complex problems. For example, creating an object like a triangle shape that is not standard to SwiftUI or modifier for a custom corner radius. It can be helpful to make shapes or helpers like this discoverable and reusable to save time for your future self to not reinvent the triangular wheel so to speak.</p><p>If we think back to building a house with LEGOs and we create a door that has a half circle brick on top of a rectangle brick we now have a standard door for all openings in the house. Any new builder that contributes to our LEGO house can look at our original door and use the same schematics to build an additional door instead of guessing sizes or LEGO pieces needed to fit in with the design of the house.</p><p>Example of reusable component:</p><pre>struct Hexagon: Shape {<br>    func path(in rect: CGRect) -&gt; Path {<br>        var path = Path()<br>        path.move(to: CGPoint(x: rect.midX/2, y: rect.minY))<br>        path.addLine(to: CGPoint(x: rect.midX*1.5, y: rect.minY))<br>        <br>        path.addLine(to: CGPoint(x: rect.maxX, y: rect.midY/2))<br>        path.addLine(to: CGPoint(x: rect.maxX, y: rect.midY*1.5))<br>        <br>        path.addLine(to: CGPoint(x: rect.midX*1.5, y: rect.maxY))<br>        path.addLine(to: CGPoint(x: rect.midX/2, y: rect.maxY))<br>        <br>        path.addLine(to: CGPoint(x: rect.minX, y: rect.midY*1.5))<br>        path.addLine(to: CGPoint(x: rect.minX, y: rect.midY/2))<br>        <br>        path.addLine(to: CGPoint(x: rect.midX/2, y: rect.minY))<br>        return path<br>    }<br>}</pre><p>Now applying it to our view:</p><pre>struct ContentView: View {<br>    var body: some View {<br>        Text(&quot;Hello, world!&quot;)<br>            .padding()<br>        Hexagon()<br>    }<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/288/1*73ZW6JoCZsUYUZGzVizapA.png" /></figure><p>Now, we can use lots of hexagon shapes in our app and add any design tweaks to the original hexagon so it’s applied throughout the app. This is a simple example that may not feel specific to SwiftUI, but think about the option to extend things like preferences, environment modifiers, or other tools to share with your team in a reusable way. SwiftUI has a great amount of resources available and we can modify or add new tools for our app when needed. Here’s a <a href="https://developer.apple.com/documentation/swiftui/path">link</a> to the Path api sharing how you can customize shapes like above.</p><p>4. Debugging with Modifiers</p><p>The border modifier in SwiftUI can be a powerful one. They are really helpful for ensuring that you’re creating the view you expect to see out in the wild. Sometimes we may think we’re following a logical order of adding modifiers to create the perfect view, but then something is off and we can’t understand why.</p><p>Let’s see how borders can help us debug the lack of a corner radius while building our view:</p><pre>Text(&quot;Text View&quot;)<br>    .foregroundColor(Color.white)<br>    .background(Color.blue)<br>    .padding(10)<br>    .cornerRadius(10)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/168/1*AjHEsKmou3oivmnr2UTiQg.png" /></figure><p>The text view might look a little funny to you, so you start to add borders to understand why it looks less rounded than you expect.</p><pre>Text(&quot;Text View&quot;)<br>    .foregroundColor(Color.white)<br>    .background(Color.blue)<br>    .padding(10)<br>    .cornerRadius(10)<br>    .border(Color.red)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/204/1*8tROIzVDo5bFgliaGDTatQ.png" /></figure><p>With the new border, our corner radius still seems to be gone 🤔</p><p>So you try:</p><pre>Text(&quot;Text View&quot;)<br>    .foregroundColor(Color.white)<br>    .background(Color.blue)<br>    .padding(10)<br>    .border(Color.red)<br>    .cornerRadius(10)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/208/1*uv6gnRPZu5hGNlWl32dAsA.png" /></figure><p>Ah, getting somewhere! Maybe the padding? Let’s try removing that and seeing the text view again.</p><pre>Text(&quot;Text View&quot;)<br>    .foregroundColor(Color.white)<br>    .background(Color.blue)<br>    .cornerRadius(10)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/180/1*fWBhwCmOz0gmcUd503Zylw.png" /></figure><p>Now we’ve got it!</p><p>When you get stuck in development mode, try to use modifiers to your advantage, whether that’s a border, background color or even print statements that will help you streamline building views.</p><p>Putting some extra focus on your view lifecycle will set you up for success. Maybe even taking some extra time separating your view from your business logic to ensure the view is only concerned with the data you’re giving it and hopefully less time debugging pesky issues. Think of it like separating your LEGOs into sizes or colors up front to save you that building time. It’ll be a lot easier to conceptualize your LEGO structure and figure out where pieces should go with that organization.</p><p>5. Smart Views</p><p>SwiftUI attempts to reload specific content that changes within the view. With SwiftUI, we observe changes with State or ObservedObject properties. Being conscious of where we create and use property wrappers in our view hierarchy will help save SwiftUI — and you — time, especially with a view that makes use of a lot of dynamic values.</p><p>We don’t need to make it harder on SwiftUI than needed. Also, beyond app performance, think about properly managing data you’d like to display. Ultimately, users will love a fast app and even in a small project, developers will enjoy these properties too!</p><p>Check out this <a href="https://www.avanderlee.com/swiftui/stateobject-observedobject-differences/">article</a> on the differences of the property wrappers mentioned above with examples.</p><p>For a smaller project this may not hinder progress or performance, but let’s keep thinking about the big pictures of our projects and who might be working on them next! Just like building with LEGO is great fun, so is sharing them with others and building more structures together. You never know if you decide to open source or onboard a lot of new teammates what might happen with a growing project.</p><p>SwiftUI is here to stay. As a new tool seamlessly integrated with Swift itself and a number of budding architectures, hopefully we can see additional features and improvements to the platform (maybe even be open sourced similarly to Swift itself!) that will continue to encourage developers to integrate SwiftUI into their projects.</p><p><em>Oh and one bonus tip — check out </em><a href="https://github.com/krzysztofzablocki/Inject"><em>Inject</em></a><em> by </em><a href="https://medium.com/u/c493366794e4"><em>Krzysztof Zabłocki</em></a><em> to debug quickly (think of all the borders you can add!). The beauty of UI updates without compiling again?? Sign us all up.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/912/1*3RXEvKNMOs-Qf788WzdHfg.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@helloimnik?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Nik</a> on <a href="https://unsplash.com/s/photos/lego?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p><em>Huge thanks to </em><a href="https://medium.com/u/bd99ef22ed4d"><em>Sarah Karp</em></a><em> for the thorough reads for grammar and helping create a cohesive storyline and Sherry Shao for the developer eyes and iOS support!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5acaf20798bf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Happiness is… a freshly organized codebase]]></title>
            <link>https://medium.com/several-people-are-coding/happiness-is-a-freshly-organized-codebase-7ffa6590a70d?source=rss-e47f010fbeae------2</link>
            <guid isPermaLink="false">https://medium.com/p/7ffa6590a70d</guid>
            <category><![CDATA[development]]></category>
            <category><![CDATA[folders]]></category>
            <category><![CDATA[code]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Erica Engle]]></dc:creator>
            <pubDate>Thu, 07 May 2020 18:52:23 GMT</pubDate>
            <atom:updated>2020-05-07T18:52:23.723Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bipan_epV7HjhXzICdoISw.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@jessedo81?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">jesse orrico</a> on <a href="https://unsplash.com/s/photos/organization?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><h3>Starting From the Top</h3><p>Imagine joining a new team at a new company and you finally get access to a codebase.</p><figure><img alt="Xcode File Hierarchy 2017" src="https://cdn-images-1.medium.com/max/874/0*JMrehlJ427nZP03E" /><figcaption>Slack iOS Xcode File Hierarchy 2017</figcaption></figure><p>Where do you add a source file for your team’s project? Great question. Your new team has three source directories for you to add files to, and oh, you’ll have to figure out which one you want to use, which one your teammate uses, and where you’re going to find the files that need refactoring.</p><p>The Slack iOS team lived in these conditions for a few too many years. We got here as a result of some attempts to organize source files (several times), a lack of architecture pattern in the codebase, and a high growth of developers over a couple years. To put things into context, we have roughly 13,000 files (and counting), about 27 top level directories, a mix of files in Objective-C and Swift, and around 40 iOS developers that work in one monorepo.</p><p>These are all real photos of the state of our file hierarchy. New hires constantly expressed frustration jumping into the codebase — and rightly so, since some of us just got used to navigating these chaotic directories and didn’t remember the pain of starting from scratch. Not only did we have numerous source code directories (our prized iOS, SlackCocoaSDK, and Slack directories), but it took a lot of time to settle on a directory and then to decide how to add a file. On top of this, we decided we wanted to add new tools to our codebase and the current state of our Xcode project did not lend well to supporting them.</p><p>As a result, a group of iOS developers and I set out on a mission:</p><ol><li>Make it quick and easy to add a new file — for any developer new or tenured</li><li>Follow our design pattern in directories</li><li>Enable ourselves to maintain a new and cleaner folder hierarchy with the use of tooling</li></ol><p>We took on these goals in two stages: move high level directories into a coherent order (things like main target directories, extension directories, frameworks etc) and then — the bigger task — source folder organization.</p><p>The top level directory moves were neither contentious nor hard. It probably took us only a few weeks with a few developers. In these first moves, we learned a few things to take into our following stage — tackling big moves during off peak work hours, consistently merging master (who wants merge conflicts?), and working with folks on timely reviews. Merge conflicts weren’t the only struggle we’d encounter during this process, but we could have invested in a better way to mitigate merge conflicts with xcodegen since most conflicts were in the project file. We also wanted to think about preserving our git history and maintaining a clear contract with how we see files displayed in git and finder. However, we opted for easy enablement of moving files to get folks involved and dragged and dropped files into their new homes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/962/0*PV3WsHV4HAaAmuNG" /><figcaption>Slack iOS Xcode Hierarchy 2017 (left) and 2018 (right)</figcaption></figure><p>If you look at this image from September 2018 you can see we were able to organize our top level fairly successfully. A place for every directory and every directory in its top level place, right?</p><h3>Source File Organization</h3><p>Time to tackle the source files in iOS, SlackCocoaSDK, and Slack to move them all into App/Source. Honestly, I dreaded this part. We needed consensus on a pattern, a clear way for developers on all teams to get involved, and both rules and tools to make sure moves were easy and clear to engineers if they had done something wrong. I did a lot of investigation into patterns for our hierarchy and there’s a surprising lack of articles on folder organization. I had thought this would be a well documented topic going into this journey, but as a less glamorous part of the job, I can understand why it isn’t covered. Of the articles I did find, Uber wrote this <a href="https://eng.uber.com/ios-monorepo/">article</a> about how they approached the move to their monorepo. This gave me some insight into how we could chunk up our codebase into modules (but on a smaller scale).</p><p>I ultimately presented three options to my greater team: Feature organization, Topic (architecture based organization), and Ontology (relationship or similar grouping based organization). The group converged on Feature for top level and then Topic or MVVM+C organization inside of those feature directories.</p><p>Here’s an example Folder in our new structure:</p><pre>/FeatureFolder<br>   /Coordinators<br>   /Models<br>   /Tests<br>      /Functional<br>      /Mocks<br>      /Unit<br>   /ViewModels<br>   /Views</pre><p>Moving the source files proved tedious and cumbersome. Merge conflicts were annoying, small things like searching for a file namespace to see if you captured all the feature files into a directory proved harder to remember than originally thought, and lots of files we were moving fell outside of the folder rules we set out initially. Thankfully, we had a few heroes step in and make some giant moves to remove iOS, SlackCocoaSDK, and Slack all into App/Source.</p><p>A snapshot of our folder hierarchy from January 2020.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/460/0*GLpsGqweNuFFrfbf" /><figcaption>Slack Xcode File Hierarchy 2020</figcaption></figure><p>While we were moving these three large source directories, we initiated a Danger rule to ensure folks would stop adding files to these directories and start using our new pattern. <a href="https://danger.systems/ruby/">Danger</a> is a tool we integrated into our Continuous Integration system that performs post-commit automated checks and posts warnings and errors onto PRs. This is what one of ours looked like:</p><pre>has_slack_directory_additions = !git.added_files.grep(/Slack/).empty?</pre><pre>has_slackcocoasdk_directory_additions = !git.added_files.grep(/SlackCocoaSDK/).empty?</pre><pre>has_ios_directory_additions = !git.added_files.grep(/iOS/).empty?</pre><pre>if has_slack_directory_additions || has_slackcocoasdk_directory_additions || has_ios_directory_additions</pre><pre>   fail(‘This PR is introducing new files into directories that are<br>   closed for adding new files. Please add files to App/Source using<br>   the new convention found in &lt;ahref=”…Adding-a-file-to-Slack-  <br>   iOS…”&gt;Adding a file to Slack iOS&lt;/a&gt;’, sticky: false)</pre><pre>end</pre><h3>Follow The Linter</h3><p>You might think “Wow, that looks great, you must be done!”. Well, not entirely. We’re still working on moving around what’s within the new source directory, App/Source. Here are some of the rules we started to implement in our “folder housekeeping”:</p><ol><li>No more spaces in folder names (those tools we want to add, like Bazel, don’t play nicely)</li><li>No more dumping ground folders like “Helper” or “Utility”</li><li>Co-locating tests (if we want to really emphasize discoverability in our new hierarchy, we need to step up this game with tests and what easier way to find a test than if it’s located in the same feature directory with the source code)</li><li>Sort your files and folders! (who doesn’t love some alphabetical ordering?!)</li><li>Make sure your files live in a folder that is associated with the proper top level directory for their target</li></ol><p>One rule that really needed tooling was co-locating tests — for this we opted for a Danger rule. Any new PR with new files added could not be added to App/Tests.</p><p>This looks something like -</p><pre>has_app_test_directory_additions = !git.added_files.grep(/Test/).empty?</pre><pre>if has_app_test_directory_additions</pre><pre>   fail(‘This PR is introducing new files into directories that are<br>   closed for adding new files. Please add co-locate tests using the<br>   new convention found in &lt;a href=”link-to-our-housekeeping-<br>   doc”&gt;iOS Folder Housekeeping Checklist&lt;/a&gt; or feel free to ask in <br>   #ios-testing-folder-structure’, sticky: false)</pre><pre>end</pre><p>The folder committee created a Slack channel where folks can ask questions if they aren’t sure where to add a file. Confusion around where to add a file happens more than you would think and even the smallest moves can have the strongest opinions attached to them.</p><p>We’ve made a lot of progress, gotten a lot of support from the greater iOS team, but still have more to do. This is not a one-person-job, you need to enlist folks who work around all parts of the codebase. You need the greater team not just for support in moving files, but for modifying rules and adding more tooling. Having the extra hands means that a lot of folks will learn the process and be able to show newer folks how adding a file in our codebase works.</p><p>The recipe for success and happiness is surprisingly short: If you are like us and have a monorepo, create a committee of folks dedicated to the process, and set hard and fast rules. Rules can be broken, but with any number of developers you may have discussions and will need a core group to create tooling to support rules for file organization to become more natural. A core committee can also spend time thinking and researching the best file structure that works for your team organization or working patterns.</p><p>It makes a world of a difference when developers understand where to add files and can do so in a way that promotes speedier development and genuinely makes it more pleasant to be inside the codebase. Tools like SwiftLint, Danger, or homegrown scripts are great for initiatives like these. However, a big caveat is that you’ll first have to get to a point where tools become useful, which usually requires non-trivial manual labor. In short: Use tools, get folks involved, and tackle it like any other project that matters for your company. It’s an undertaking, but making it easier for everyone to find or add a file, allowing developers to understand our architecture pattern, and enabling tooling to enforce and promote a cleaner codebase is definitely worthwhile.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7ffa6590a70d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/several-people-are-coding/happiness-is-a-freshly-organized-codebase-7ffa6590a70d">Happiness is… a freshly organized codebase</a> was originally published in <a href="https://medium.com/several-people-are-coding">Several People Are Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>