<?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 Mateusz Kuźnik on Medium]]></title>
        <description><![CDATA[Stories by Mateusz Kuźnik on Medium]]></description>
        <link>https://medium.com/@mateuszkunik?source=rss-c6e7f6381684------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*dmbNkD5D-u45r44go_cf0g.png</url>
            <title>Stories by Mateusz Kuźnik on Medium</title>
            <link>https://medium.com/@mateuszkunik?source=rss-c6e7f6381684------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 04:26:20 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mateuszkunik/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[How to handle keyboard behavior in iOS apps]]></title>
            <link>https://medium.com/azimolabs/how-to-handle-keyboard-behavior-in-ios-apps-3098a8c5411a?source=rss-c6e7f6381684------2</link>
            <guid isPermaLink="false">https://medium.com/p/3098a8c5411a</guid>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[user-experience]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Mateusz Kuźnik]]></dc:creator>
            <pubDate>Tue, 25 May 2021 11:30:33 GMT</pubDate>
            <atom:updated>2021-05-25T11:30:33.432Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J3LpKpgYcKcZjqSW6BlBIA.png" /></figure><h4>Make on-screen keyboard and application UI friends</h4><p>In the mobile world, the on-screen keyboard is an inseparable part of almost all apps. We should never ignore how impactful it can be on user experience. In the end, it takes nearly half of the screen. With its dynamic size, sometimes changing on the fly, it can make your UI clunky and bring many frustrations to your customers.</p><p>This article will walk you through some of our experiences in making the Azimo iOS app layout working smoothly with the on-screen keyboard.</p><p>In the beginning, let’s take a look at the API provided by Apple in the UIKit. We can register observers to the NotificationCenter, which will notify us when the keyboard frame change:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d3f5e6c1932f537f31e12882ee373834/href">https://medium.com/media/d3f5e6c1932f537f31e12882ee373834/href</a></iframe><p>All of those notifications come with a set of helpful information required to layout our UI correctly. We can find them in the userInfo property:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f5ec403d71329339ba2d0a055bc23719/href">https://medium.com/media/f5ec403d71329339ba2d0a055bc23719/href</a></iframe><p><em>The </em><em>UIKeyboardBoundsUserInfoKey is deprecated, and you should not use it!</em></p><p>The most common solution to handle keyboard appearance is registering for UIResponder.keyboardWillShowNotification and UIResponder.keyboardWillHideNotification<strong><em> </em></strong>notifications in a <strong>ViewController</strong> instance. And then update the layout for each invocation by updating the insets of the scroll view.</p><p>This approach is good if you have only one place in the app with user input fields. When you have more places like this, you need to copy-paste the code and adjust it.</p><p>To avoid creating boilerplate, we can rely on another UIKit solution — <a href="https://developer.apple.com/documentation/uikit/uiview/positioning_content_relative_to_the_safe_area">Safe Area</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mIAdmk4zG1IBRXosw9V7Ig.png" /><figcaption>Safe Area presentation form UIKit documentation (<a href="https://developer.apple.com/documentation/uikit/uiview/positioning_content_relative_to_the_safe_area">link</a>)</figcaption></figure><p>Safe Area is a layout guide that represents available space for your app’s content. To use it, you can connect your views to it and rely on AutoLayout to handle all changes for you. Safe Area takes into account things like navigation bars, so you are sure that they never overlap your content.</p><p>Why not make Safe Area aware of keyboard size then, so the AutoLayout engine handles its appearance for us?</p><p>Sadly it’s not possible to create a code like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a3c8a3f7bb911cde10e970b890eab978/href">https://medium.com/media/a3c8a3f7bb911cde10e970b890eab978/href</a></iframe><p>It’s because UIView.safeAreaInsets<strong><em> </em></strong>property is read-only.</p><p>Fortunately, we can adjust the view controller’s safe area by modifying the <strong><em>UIViewController.additionalSafeAreaInsets</em></strong> property.</p><h4>KeyboardAppearListener, our remedy</h4><p>Let’s build an elegant and reusable solution step by step.<br>Firstly, we will create an object that holds our logic to reuse it in multiple places.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e6a34ee3e7e2ed74c694d07154e08820/href">https://medium.com/media/e6a34ee3e7e2ed74c694d07154e08820/href</a></iframe><p>The first two properties are helper objects to handle the notification logic. I recommend you to check out this <a href="https://oleb.net/blog/2018/01/notificationcenter-removeobserver/">article</a> from <strong>Ole Begeman</strong> for more.</p><p>For now, the code is obvious. We register for the UIResponder.keyboardWillShowNotification and UIResponder.keyboardWillHideNotification notifications which call our internal functions.</p><p>Now, let’s implement our keyboardWillShow function. In the beginning, we need to set up a guard to make sure that all required data is available:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/96f25d1373b4192995cf73e3c46b8029/href">https://medium.com/media/96f25d1373b4192995cf73e3c46b8029/href</a></iframe><p>We need to get the beginning and the end frame and compare these values. This check is not required, but there is no point in performing the rest of the logic if nothing changed. And this can happen many times as the system posts a notification each time the user taps on the text field (even the same).</p><p>Next, we calculate the new safe area insets for the keyboard.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f950fbd919ef4a4a24aa02f485e205f1/href">https://medium.com/media/f950fbd919ef4a4a24aa02f485e205f1/href</a></iframe><p>It could sound reasonable to use the keyboard height, but the system calls our logic for each frame change. For example, when you switch from the default text field to the email field, the system may add a view with email addresses to select. For that reason, we use the difference between the Y value.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/222/1*Qf4JAXjmsKtiz7Pf8crGqA.gif" /></figure><p>We need to remember that the system attaches the keyboard to the screen’s bottom edge, and we are calculating the additional safe area. It means that the computed bottom inset is too big. To fix this, we need to subtract the “window” safe area bottom inset. We do not have access to this value directly, but we can easily calculate it. And of course, we want to do it only once, so we need to add a new variable windowsSafeAreaWereAdded to our class.</p><p>The final version is:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/961ac810dda7a52cb0ea1d1793b3a113/href">https://medium.com/media/961ac810dda7a52cb0ea1d1793b3a113/href</a></iframe><p>In the end, to be a good citizen, we should animate our changes along with the keyboard’s appearance animation.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/aecd55b96a6cf516a6ac8db7a840398a/href">https://medium.com/media/aecd55b96a6cf516a6ac8db7a840398a/href</a></iframe><p>The body of the keyboardWillHide function is almost identical. The difference is in the math we use to calculate the additional safe area insets.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/222/1*pxOlFRtRQlcYnlWOjC3NuA.gif" /></figure><p>We are almost there. The code works well as long as we do not rotate the device while the keyboard is on the screen. In that case, our math does not work anymore. Why? It’s because of how the iOS informs us about the change. The flow is:</p><ol><li>the user rotates the device</li><li>the system performs rotations</li><li>the system pushes the <strong>UIResponder.keyboardWillHideNotification</strong> notification,</li><li>the system pushes the <strong>UIResponder.keyboardWillShowNotification</strong> notifications.</li></ol><p>The order of those steps is the key here. After a rotation, the bottom size of the safe area is different. If you remember, we calculate the safe area each time we need to use it. This causes that after rotation (when the keyboard will hide is performed), we use a different value for the <strong>windowSafeArea</strong> than was used to calculate the additional safe area. To fix that, we need to store the previously used value in the local variable and use it instead of calculating it.</p><p>Now, all you need to do is create the instance of the <strong>KeyboardAppearListener</strong> and store it as long as your view controller is alive.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/222/1*y_desj6I35o17hIbyF9pqw.gif" /><figcaption>On this animation, you can see the sticky button. If you are interested in how to implement it with a similar approach, stay tuned 😉.</figcaption></figure><p>Here is the final implementation of our <a href="https://gist.github.com/matkuznik/209fd435b97dc8713cf0d5afbe7419b3"><strong>KeyboardAppearListener</strong></a>. We do not create a separate framework for it as the class has less than 90 lines.</p><p>P.S. If you do not like the fact that we have to change the state by modifying the windowSafeArea and windowsSafeAreaWereAdded you are not alone. I’m not too fond of it as well. If you have an idea how to get rid of it, drop us a message!</p><h3>Towards financial services available to all</h3><p>We’re working throughout the company to create faster, cheaper, and more available financial services all over the world, and here are some of the techniques that we’re utilizing. There’s still a long way ahead of us, and if you’d like to be part of that journey, check out our <a href="http://bit.ly/3vajnu6">careers page</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3098a8c5411a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/azimolabs/how-to-handle-keyboard-behavior-in-ios-apps-3098a8c5411a">How to handle keyboard behavior in iOS apps</a> was originally published in <a href="https://medium.com/azimolabs">AzimoLabs</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 the perfect dependencies manager for iOS]]></title>
            <link>https://medium.com/azimolabs/whats-the-perfect-dependencies-manager-for-ios-8a2f80bca53a?source=rss-c6e7f6381684------2</link>
            <guid isPermaLink="false">https://medium.com/p/8a2f80bca53a</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[swift-package-manager]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[carthage]]></category>
            <dc:creator><![CDATA[Mateusz Kuźnik]]></dc:creator>
            <pubDate>Wed, 31 Mar 2021 06:58:51 GMT</pubDate>
            <atom:updated>2021-03-31T06:58:51.164Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ryFtkvKf9WgX1PiJVUEgNg.jpeg" /></figure><h4>Our journey through CocoaPods, Carthage, and Swift Package Manager</h4><p>Azimo’s iOS application went through many steps and turnovers over time. Some of the solutions that served us well in the past became obstacles in development speed, quality of our product, and growing codebase. This post discusses one of these experiences — working with dependencies managers, <a href="https://cocoapods.org/">CocoaPods</a>, <a href="https://github.com/Carthage/Carthage">Carthage</a>, and <a href="https://swift.org/package-manager/">Swift Package Manager</a>, and migrating our project between them.</p><h3><strong>CocoaPods</strong></h3><p>When we started our iOS app development, Swift language wasn’t stable enough to use in the commercial product. Back then, CocoaPods was a default option for the majority of iOS projects. So it was for us.</p><p>CocoaPods brings a lot of simplifications into dependencies management:</p><ul><li>Dependencies are managed from a single place. You don’t have to download them from their websites or repositories.</li><li>Thanks to Podfile, your teammates don’t have to search through the project to check which dependencies are installed.</li><li>Some of the dependencies have their own dependencies. CocoaPods take care of figuring that out for you.</li><li>Updating dependencies is much simpler. Just bump version name in a Podfile, run pod install in a terminal, and you are home.</li><li>CocoaPods is a well-known solution across the iOS engineering world. Most of your questions are already answered. Even now, CocoaPods remains the default dependency manager for engineers who are creating their libraries and SDKs.</li></ul><p>Here’s how to start with CocoaPods.</p><p>Podfile with:</p><pre>platform :ios, &#39;10.0&#39;<br>use_frameworks!<br><br>target &#39;MyApp&#39; do<br>  pod &#39;AFNetworking&#39;, &#39;~&gt; 4.0.1&#39;<br>  pod &#39;Firebase/RemoteConfig&#39;, &#39;~&gt; 7.9.0&#39;<br>end</pre><p>and terminal command:</p><pre>$ pod install</pre><p>This is all you need to start using it in your project. For the exact setup, visit <a href="https://cocoapods.org/">https://cocoapods.org/.</a></p><h4><strong>Cons of using CocoaPods</strong></h4><p>CocoaPods simplicity comes with a cost that became more visible when your project grows bigger. Here are some of the challenges that forced us to consider migration into a different solution:</p><ul><li>Adding non-public/internal frameworks requires extra work with <a href="https://guides.cocoapods.org/making/private-cocoapods.html">Private Spec Repo</a>. Because some of our dependencies weren’t publicly available and others are our own internal libraries, we needed to spend some time modifying .podspec files.</li><li>CocoaPods makes changes in the project’s configuration file project.pbxproj. If something goes wrong, it can affect the building process. Debugging takes a lot of time and requires understanding the changes that CocoaPods introduced under the hood.</li><li>When you decide to remove a framework, not all of the changes are cleaned up. Over the years, these leftovers stack up.</li><li>CocoaPods require a Ruby environment. It’s another thing that you need to keep in sync with all of the machines.</li></ul><h3><strong>Carthage</strong></h3><p>A couple of years ago, we decided to migrate our dependency management from CocoaPods to <a href="https://github.com/Carthage/Carthage">Carthage</a> because of the things mentioned above. For a startup company, the early years mean a lot of experimentations and pivoting. During our journey, we introduced many changes in 3rd party solutions within a short time. Constant changes in libraries resulted in a growing mess in our project configuration file. The stability of our CI/CD pipelines decreased too.</p><p>After the migration, Carthage solved some of our problems. Here are the pros of this tool that made our engineer’s life easier:</p><ul><li>Adding new dependency doesn’t change your project configuration at all. Carthage builds dependencies using xcodebuild and doesn’t touch project.pbxproj file. It also means that it’s now the developer’s responsibility, but it was a good thing for us. It brought us better control over our app’s codebase and simplified debugging process when something went wrong.</li><li>As contrary to CocoaPods, Carthage builds dependencies only once, during the resolution process. They are then added to the project as a framework, so we don’t have to rebuild them each time.</li><li>Private repositories don’t require any additional setup. Carthage can point out git repositories and get sources from there.</li><li>Carthage doesn’t require a Ruby environment (and any other one). It can be installed via Homebrew or as a .pkg file. No more version sync between your teams’ computers and CI/CD. 👍</li><li>When it comes to CI/CD, there is also a great caching solution that we have been heavily using to share dependencies between our pipelines. It’s called <a href="https://github.com/tmspzz/Rome">Rome</a>.</li></ul><p>While the decision about migrating our project to Carthage was an excellent move for us, this tool also has some cons:</p><ul><li>In our case, It took a lot of time to resolve dependencies. In the best-case scenario (everything’s cached), it’s a couple of seconds. But In the worst case, <strong>from 5 to even 35 minutes 😱 </strong>(no cache, full resolution). It can be painful if you are working on an internal framework and the app simultaneously. Each change in a framework needs to be pushed to the repository and resolved on the app’s side. (It is possible to make changes locally, but the solutions aren’t straightforward, yet the dependencies still need to be resolved as usual).</li><li>Carthage builds all of the schemes in each project, even if it is not required. Some projects contain a demo app (sometimes even more than one) with a shared scheme. Because of them, building time adds up.</li><li>Additional Build Phase for each library is required.</li><li>We had a hard time when doing the project’s migration to Xcode 12. Since the Apple Silicon introduction, Carthage made our compilation failing in a nasty way. You can find more details and the solution for that <a href="https://github.com/Carthage/Carthage/blob/master/Documentation/Xcode12Workaround.md">here</a>.</li></ul><h3><strong>Swift Package Manager</strong></h3><p>The challenges mentioned above (especially resolution time) made us consider using another dependency manager solution, <strong>Swift Package Manager</strong>. We are in the middle of the migration process between Carthage and SPM, yet even now, results are promising.</p><p>The things which SPM makes better in the context of our project are:</p><ul><li>It has better support for the internal frameworks. To work on a framework and the app simultaneously, we just need to drag and drop the first one into the Xcode project’s navigator.</li><li>As contrary to Carthage, SPM builds what is required (no more rebuilds of demo projects) and doesn’t need an extra step in <strong>Build Phase</strong>,</li><li>Because of Apple’s official support, we hope to have no more issues when moving to a newer version of Xcode. 🤞🏻</li><li>After migrating from CocoaPods to Carthage, we removed the Ruby framework. With SPM, we don’t require any additional installation (which was the case for Carthage). The entry-level of our project is even lower.</li><li>It also means fewer steps to perform in Terminal to resolve all dependencies. Everything is part of Xcode now.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/1*3PSV-Z2Wv7uun-aJIm1WjA.gif" /><figcaption>Adding dependency in SPM is just drag’n’drop 👍</figcaption></figure><p>We also started noticing the global industry trend of migrating into this SPM dependency manager. Some of our partners have already dropped support for Carthage in favor of Swift Package Manager.</p><p>Of course, SPM isn’t perfect. Even if we think that it’s now better than CocoaPods and Carthage, there are still some challenges to keep in mind. The biggest ones for us are:</p><ul><li>Currently, caching mechanisms seem to be problematic, especially in the context of CI/CD. Xcode has its internal cache, which isn’t publicly described. It raises a question mark around how it’ll work if CI/CD runs multiple pipelines which use different versions of dependencies.</li><li>Not all frameworks support SPM. Our ecosystem isn’t there yet.</li><li>And close to the one above — we still face problems, especially with frameworks that need to be used in the Objective-C code. These don’t look like SPM’s problem, yet made us having some difficult times.</li></ul><h3><strong>How to migrate your project from Carthage to Swift Package Manager</strong></h3><p>Here is our internal, step by step instruction for how you can migrate each framework from Carthage to SPM:</p><ol><li>Select the framework you want to migrate</li><li>Remove the framework(s). Please, have in mind that one framework can have multiple products:<br>• Find the framework in the navigator.<br>• Delete it.</li><li>Remove the framework from the Cartfile file.</li><li>Remove the framework from the Cartfile.resolved file.</li><li>Remove the framework from the Carthage.xcfilelist.</li><li>Remove the framework from the Carthage’s <strong>PhaseScript</strong> for each target if needed:<br>• For most of the frameworks, this step should is not required because of Carthage.xcfilelist file.<br>• In the Navigator, select the main project.<br>• In the Targets section, select a target you want to include in the new framework.<br>• Select the <strong>Build Phases</strong> tab<br>• Select the Carthage section and remove the framework</li><li>Remove the framework from the Romefile file.</li><li>Add a new <strong>SPM</strong> entry:<br>• For most cases, we want to use the Exact version and update them manually.<br>• Select product(s) and a target to which the entry should be added.<br>• Now we can choose only one target. We will add it to others later.<br>•Add the new framework to the required targets if needed.<br>• In the <strong>Navigator</strong>, select the main project.<br>• In the <strong>Targets</strong>, section selects a target you want to include in the new framework.<br>• Select the <strong>Build Phases</strong> tab<br>• Add all required frameworks to <strong>Link Binary With Libraries</strong>.</li><li>To test the integration:<br>• Clean project or empty the DerivedData folder<br>• Build and Run project<br>• Archive project</li></ol><h3>Towards financial services available to all</h3><p>We’re working throughout the company to create faster, cheaper, and more available financial services all over the world, and here are some of the techniques that we’re utilizing. There’s still a long way ahead of us, and if you’d like to be part of that journey, check out our <a href="http://bit.ly/3vajnu6">careers page</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8a2f80bca53a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/azimolabs/whats-the-perfect-dependencies-manager-for-ios-8a2f80bca53a">What’s the perfect dependencies manager for iOS</a> was originally published in <a href="https://medium.com/azimolabs">AzimoLabs</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>