<?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 Krishna Prakash on Medium]]></title>
        <description><![CDATA[Stories by Krishna Prakash on Medium]]></description>
        <link>https://medium.com/@krishnaprakashn?source=rss-d28ec9c3baf9------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*PCmEfl6K3VjsxN547vd9ow.jpeg</url>
            <title>Stories by Krishna Prakash on Medium</title>
            <link>https://medium.com/@krishnaprakashn?source=rss-d28ec9c3baf9------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 05:38:36 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@krishnaprakashn/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[The iOS Release Playbook: How to Ship Apps Without Stress]]></title>
            <link>https://medium.com/@krishnaprakashn/the-ios-release-playbook-how-to-ship-apps-without-stress-afcb71531fb9?source=rss-d28ec9c3baf9------2</link>
            <guid isPermaLink="false">https://medium.com/p/afcb71531fb9</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[ios-development]]></category>
            <category><![CDATA[quality-assurance]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[swift]]></category>
            <dc:creator><![CDATA[Krishna Prakash]]></dc:creator>
            <pubDate>Wed, 17 Dec 2025 10:33:55 GMT</pubDate>
            <atom:updated>2025-12-18T16:21:57.082Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ijFUZCDQGfjjMUNxf6672A.png" /></figure><p>Releasing an iOS app shouldn’t feel like a roll of the dice. More often than not, the risk comes not from complex architecture or elusive bugs — it comes from the small, overlooked details that quietly sabotage a release.</p><p>The best engineering teams don’t rely on luck. They rely on <strong>repeatable systems</strong>. This guide condenses years of shipping experience into a point-based playbook to eliminate “release day anxiety” and ensure your build is rock-solid before it hits the App Store.</p><h3>🏗️ 1. Build &amp; Configuration Readiness</h3><p>The foundation of a reliable release is a well-configured environment. A single misplaced key here can break the entire user experience.</p><ul><li><strong>Feature Flag Audit:</strong> Review all flags affecting user behavior. Confirm that <strong>Production defaults</strong> are set and purge any “dead” or experimental flags.</li><li><strong>Environment Validation:</strong> Hard-verify that the app is pointing to Production API endpoints, not Staging or UAT.</li><li><strong>Capability Clean-up:</strong> Review entitlements (Push, Background Modes, Sign in with Apple). Remove unused capabilities to reduce your <strong>App Store rejection risk</strong>.</li><li><strong>Secrets &amp; Certificates:</strong> Confirm environment variables and provisioning profiles match the release setup. Misaligned certs are a painful source of last-minute failures.</li></ul><h3>🌍 2. Localization &amp; Regional Integrity</h3><p>Small localization mistakes can ruin the user experience for an entire country.</p><ul><li><strong>Bundle Cleanup:</strong> Verify only supported languages are included. Ensure no “test” or “pseudo-languages” are accidentally shipping.</li><li><strong>The Fallback Test:</strong> Change a device to an unsupported language and verify the app defaults gracefully (usually to English).</li><li><strong>Privacy Transparency (The 2025 Standard):</strong> Apple’s <strong>Privacy Nutrition Labels</strong> are now a primary rejection trigger. If you have added a new SDK — even for something as simple as analytics — your labels must reflect it. <strong>The Mapping Sample:</strong> If you integrate a tool like <em>Firebase Analytics</em> or <em>Mixpanel</em>, you must manually update App Store Connect to disclose:<br> <strong>Usage Data:</strong> (Product Interaction)<br> <strong>Identifiers:</strong> (Device ID)<br> <strong>Diagnostics:</strong> (Crash Logs)<br><strong>Pro-Tip:</strong> Check the SDK provider’s documentation; most major libraries now provide a “Privacy Label Cheat Sheet” to help you stay compliant.</li></ul><h3>🧪 3. Quality &amp; Stability Guardrails</h3><p>A green CI/CD pipeline is a start, but it isn’t a guarantee.</p><ul><li><strong>Fresh Eyes Smoke Test:</strong> Perform a <strong>fresh install</strong> on a physical device. Manually walk through onboarding and the “happy path.” Automated tests often miss UI layering issues.</li><li><strong>Local Test Runs:</strong> Run Unit and UI tests locally once. Pipelines can be flaky; seeing a green light on a real machine builds true confidence.</li><li><strong>Accessibility Check:</strong> Ensure your app respects <strong>Dynamic Type</strong>. If your UI breaks when a user increases font size, you are alienating up to 20% of your potential audience.</li></ul><h3>📊 4. Observability &amp; Analytics</h3><p>If it isn’t measured, it didn’t happen.</p><ul><li><strong>Telemetry Check:</strong> Confirm Analytics SDKs are initializing and firing key events. Don’t let a release break your business intelligence.</li><li><strong>Crash Reporting &amp; dSYMs:</strong> Ensure your crash reporter is active and that <strong>debug symbols (dSYMs)</strong> are uploaded. Without these, your crash logs are unreadable.</li><li><strong>The “Kill Switch”:</strong> Verify your remote configuration allows you to disable a broken feature instantly without waiting for a new App Store review cycle.</li></ul><h3>🚀 5. App Store Submission Strategy</h3><p>The final gate is about more than just clicking “Submit.”</p><ul><li><strong>Versioning Logic:</strong> Match the App Store version with your internal build number. Mismatches create a nightmare for support and bug tracking.</li><li><strong>User-Centric Release Notes:</strong> Swap “Bug fixes and performance improvements” for notes that provide actual value. Your audience is the <strong>customer</strong>, not your Jira board.</li><li><strong>Reviewer Readiness:</strong> Ensure demo credentials are valid. If your app requires hardware (like a Bluetooth device), provide a <strong>video link</strong> in the Review Notes to help the reviewer pass you faster.</li></ul><h3>⚖️ 6. Ownership &amp; Post-Release</h3><p>Shipping is only the beginning of the lifecycle.</p><ul><li><strong>Rollout Strategy:</strong> Decide in advance: Manual, <strong>Phased (7-day)</strong>, or Immediate. Phased rollouts are the gold standard for risk mitigation.</li><li><strong>Assigned Pilots:</strong> Identify a <strong>Release Owner</strong> to drive the process and a <strong>Monitoring Owner</strong> to watch logs and early App Store reviews for the first 4 hours or couple of days.</li><li><strong>The Post-Mortem:</strong> Schedule a “Release Retro.” Document every friction point and update this checklist. Every release should be easier than the last.</li></ul><h3>💡 The Bottom Line</h3><p>A stable release isn’t about heroics; it’s about <strong>consistency, clarity, and accountability</strong>.</p><p>This playbook won’t make your app perfect, but it will make your releases predictable. Adapt these points to your team’s workflow, and watch “release day stress” disappear — replaced by the confidence that your app is ready for the world.</p><p><strong>Enjoyed this playbook?</strong> &gt; If this guide helps you ship with more confidence, give it a few 👏 <strong>claps</strong> and <strong>follow</strong> for more deep dives into professional iOS engineering. I’d love to hear from you — what is the one “silent killer” that has crashed your release in the past? Let me know in the comments!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=afcb71531fb9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building an iOS App with MVVM and Clean Architecture: A Practical Guide]]></title>
            <link>https://medium.com/@krishnaprakashn/building-an-ios-app-with-mvvm-and-clean-architecture-a-practical-guide-16c0fd74ca44?source=rss-d28ec9c3baf9------2</link>
            <guid isPermaLink="false">https://medium.com/p/16c0fd74ca44</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[mvvm]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[clean-architecture]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Krishna Prakash]]></dc:creator>
            <pubDate>Mon, 12 Aug 2024 18:02:39 GMT</pubDate>
            <atom:updated>2024-11-26T10:57:48.255Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>In modern iOS app development, choosing the right architecture is crucial for maintaining scalability, testability, and a clean codebase. One of the most popular combinations is the Model-View-ViewModel (MVVM) pattern integrated with Clean Architecture principles. This approach allows developers to separate concerns, making the code easier to maintain and extend.</p><p>In this article, we will walk through building a sample iOS app using Swift and SwiftUI, adhering to the MVVM+Clean architecture. By the end of this tutorial, you’ll have a solid understanding of how to structure your projects for clarity and efficiency.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7P6tD5rS8WRCMcdUk6iE4g.png" /></figure><h3>1. Understanding the Architecture</h3><p>To effectively build an app using MVVM+Clean architecture, it’s important to understand how each layer functions and interacts with others. Let’s break down the architecture into three main layers: Presentation, Domain, and Data.</p><h4>Presentation Layer</h4><p>The Presentation Layer is responsible for everything the user sees and interacts with. This includes views, which display data, and view models, which handle the logic for displaying this data.</p><ul><li><strong>Views:</strong><br>The views in this architecture are typically built using SwiftUI. They are responsible for displaying data and handling user interactions. In SwiftUI, views are declarative, meaning that they are rebuilt every time their state changes.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/888/1*CuLreTFTtgKxNsz5hbzpPA.png" /><figcaption>Example SwiftUI View</figcaption></figure><ul><li><strong>ViewModels:</strong> <br>ViewModels handle the presentation logic and act as intermediaries between the View and the UseCase. They fetch data from UseCases, process it, and expose it in a format that can be easily consumed by the View.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/966/1*HV4GZwCyt573BSoqtRE75A.png" /><figcaption>Example View Model</figcaption></figure><h4>Domain Layer</h4><p>The Domain Layer contains the business logic of the app. This layer is independent of any UI or data framework, making it reusable and easy to test.</p><ul><li><strong>UseCases:</strong> <br>UseCases encapsulate the specific business rules of your app. They coordinate the flow of data between the repository and the ViewModel, ensuring that the data is processed according to the business logic.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/998/1*lzH4KTOz2mTdvSCk-eXaLQ.png" /><figcaption>Example UseCase</figcaption></figure><ul><li><strong>Entities:</strong> <br>Entities represent the core business model of your application. They are pure Swift structures or classes that define the properties and behaviour of business objects.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/914/1*2Ls9pbWmzY2Rr4ZZcBxlCg.png" /><figcaption>Example Entity/Model</figcaption></figure><h4>Data Layer</h4><p>The Data Layer is responsible for providing data to the Domain Layer, usually by interacting with external APIs or local databases. This layer abstracts away the details of data fetching and storage, allowing the Domain Layer to remain clean and focused on business logic.</p><ul><li><strong>Repositories:</strong> <br>Repositories provide a clean API for the Domain Layer to interact with data sources. They hide the complexities of data retrieval and caching, offering a simple interface to the UseCases.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e2xJDUS1AO2f1yO7Zl3A0w.png" /><figcaption>Example Repository</figcaption></figure><blockquote><strong>DataSources:</strong> DataSources are responsible for fetching data, either from a remote source (like an API) or a local source (like a database). They are the building blocks that Repositories use to get data.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ki3ZbufMc87wUDdvTS1kwQ.png" /></figure><p>Network Service:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k359T5pHFwaM1FvuROpyiw.png" /></figure><h3>2. Setting Up the Project</h3><p>Before we dive into the code, let’s set up the project and organize the files according to the MVVM+Clean architecture.</p><ol><li><strong>Create a New iOS Project:</strong></li></ol><ul><li>Open Xcode and create a new SwiftUI project.</li><li>Name your project and select the appropriate options.</li></ul><p>2.<strong> Organize Your Folder Structure:</strong></p><ul><li>Create folders for each layer: Presentation, Domain, and DataLayer.</li><li>Within each folder, organize files based on their roles, as shown in the screenshot.</li></ul><p><strong>Folder Structure Example:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/542/1*3ImpT9H2pg7Xw3yewsVxZA.png" /><figcaption>Folder Structure</figcaption></figure><h3>Bringing It All Together</h3><p>Now that we have our layers set up, let’s walk through the flow of data from the Data Layer to the Presentation Layer.</p><ul><li><strong>Step 1:</strong> The ViewModel requests data from the UseCase.</li><li><strong>Step 2:</strong> The UseCase interacts with the Repository to fetch the data.</li><li><strong>Step 3:</strong> The Repository fetches data from the DataSource.</li><li><strong>Step 4:</strong> The data flows back through the Repository and UseCase to the ViewModel.</li><li><strong>Step 5:</strong> The ViewModel updates the View with the new data.</li></ul><p>This flow ensures a clean separation of concerns, making the app easier to maintain and extend.</p><h3>Testing</h3><p>Testing is an essential part of app development. Here’s a brief overview of how to unit test the different layers of the MVVM+Clean architecture.</p><ul><li><strong>ViewModels:</strong> Test the presentation logic by mocking the UseCases and checking how the ViewModel reacts to different data scenarios.</li><li><strong>UseCases:</strong> Test the business logic by mocking the Repositories and verifying that the correct data is processed.</li><li><strong>Repositories:</strong> Test the data fetching logic by mocking the DataSources and ensuring that data is correctly retrieved and processed.</li></ul><h3>Advantages of Clean Architecture</h3><p>When implementing Clean Architecture in your iOS app, you will benefit from several key advantages:</p><ol><li><strong>Separation of Concerns:</strong></li></ol><ul><li><strong>Domain Layer:</strong> Focuses on business logic and domain models, making it independent of UI and data sources.</li><li><strong>Data Layer:</strong> Handles data operations, APIs, and repositories, ensuring that data management is abstracted from other layers.</li><li><strong>Presentation Layer:</strong> Manages UI and user interactions, making it easy to test and maintain.</li></ul><p>2. <strong>Testability</strong></p><ul><li>Each layer can be tested independently, ensuring higher test coverage and easier debugging.</li><li>Use cases in the domain layer can be unit-tested without relying on the data layer or the UI.</li></ul><p>3. <strong>Scalability</strong></p><ul><li>The clear separation of responsibilities makes it easier to scale the app as the project grows.</li><li>Adding new features becomes easier as changes in one layer have minimal impact on others.</li></ul><p>4. <strong>Maintainability</strong></p><ul><li>Clean Architecture promotes better code organization, making it easier to maintain and update the codebase.</li><li>Changes in business logic or data sources can be handled independently without affecting the UI or other parts of the system.</li></ul><p>5. <strong>Flexibility</strong></p><ul><li>The architecture is flexible enough to handle changes in requirements and technology stacks.</li><li>You can switch from REST to GraphQL or change the UI framework without major refactoring.</li></ul><h3>Potential Challenges</h3><p>While Clean Architecture offers many advantages, there are some challenges you might face when adopting it:</p><ul><li><strong>Initial Complexity:</strong> Clean Architecture can introduce some complexity upfront, requiring more boilerplate code and a clearer understanding of the architectural principles.</li><li><strong>Learning Curve:</strong> Your team might need to invest time in learning and understanding Clean Architecture, especially if they are not familiar with it.</li></ul><h3>Code Repository</h3><p>For the complete code of the sample project discussed in this article, visit Git <a href="https://github.com/kittu4ios/MVVM-Clean-Swift.git"><strong>Download</strong></a></p><h3>Conclusion</h3><p>By implementing the MVVM+Clean architecture, you create an iOS app that is not only well-structured but also easy to maintain, test, and extend. This architecture promotes separation of concerns, making the app scalable and resilient to changes.</p><p><strong>In my next blog, I will go deeper into MVVM+Clean architecture by introducing the Coordinator design pattern, often referred to as MVVM+C.</strong> This powerful combination enhances app flow and organization, making navigation and dependency management more robust. Stay tuned for a comprehensive guide!</p><p>I encourage you to explore and implement this architecture in your projects to reap its benefits.</p><p>We’d love to hear your thoughts! Please share your feedback in the comments section, and if you found this article valuable, don’t forget to give it <strong>50 claps</strong> (or as many as you think it deserves)! 👏 Your support helps us continue to provide useful content. Thank you!</p><p>Happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=16c0fd74ca44" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Advanced Swift iOS: Custom CodingKey with convertFromSnakeCase Decoding Strategy]]></title>
            <link>https://medium.com/@krishnaprakashn/advanced-swift-ios-custom-codingkey-with-convertfromsnakecase-decoding-strategy-808bf870b8dc?source=rss-d28ec9c3baf9------2</link>
            <guid isPermaLink="false">https://medium.com/p/808bf870b8dc</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[json]]></category>
            <category><![CDATA[swift-programming]]></category>
            <dc:creator><![CDATA[Krishna Prakash]]></dc:creator>
            <pubDate>Tue, 06 Aug 2024 10:55:36 GMT</pubDate>
            <atom:updated>2024-09-25T08:16:07.442Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gATsQwyz68AybLyp5mYWsg.png" /></figure><p>In Swift, working with JSON data often requires converting keys from one format to another. One common transformation is from snake_case to camelCase. Swift’s JSONDecoder offers a convertFromSnakeCase key decoding strategy to automate this conversion. However, when you need to set custom CodingKey values or handle special cases with underscores, the process can get a bit more involved. This guide will walk you through using convertFromSnakeCase with custom CodingKey implementations and handling special underscore scenarios.</p><h3>Case 1: Basic Usage of .convertFromSnakeCase</h3><p>The convertFromSnakeCase strategy simplifies decoding JSON with snake_case keys into Swift’s camelCase property names. Here’s a basic example:</p><pre>import Foundation<br><br>struct BasicUser: Codable {<br>    var firstName: String<br>    var lastName: String<br>}<br><br>let jsonData = &quot;&quot;&quot;<br>{<br>    &quot;first_name&quot;: &quot;Krishna&quot;,<br>    &quot;last_name&quot;: &quot;Prakash&quot;<br>}<br>&quot;&quot;&quot;.data(using: .utf8)!<br><br>let decoder = JSONDecoder()<br>decoder.keyDecodingStrategy = .convertFromSnakeCase<br><br>do {<br>    let user = try decoder.decode(BasicUser.self, from: jsonData)<br>    print(user)<br>    // Output: BasicUser(firstName: &quot;Krishna&quot;, lastName: &quot;Prakash&quot;)<br>} catch {<br>    print(error)<br>}</pre><h3>Case 2: Customizing CodingKey</h3><p>Sometimes, you need to map JSON keys to property names that don’t directly follow snake_case to camelCase conventions. In this case, you can use custom CodingKey values:</p><pre>import Foundation<br><br>struct DemoUser: Codable {<br>    var id: String<br>    var name: String<br>    var email: String<br><br>    enum CodingKeys: String, CodingKey {<br>        case id = &quot;user_id&quot;<br>        case name = &quot;user_name&quot;<br>        case email = &quot;user_email&quot;<br>    }<br>}<br><br>let userJsonData = &quot;&quot;&quot;<br>{<br>    &quot;user_id&quot;: &quot;ABCD1528&quot;,<br>    &quot;user_name&quot;: &quot;Krishna&quot;,<br>    &quot;user_email&quot;: &quot;kpmobileappdeveloper@gmail.com&quot;<br>}<br>&quot;&quot;&quot;.data(using: .utf8)!<br><br>let decoder1 = JSONDecoder()<br><br>do {<br>    let user = try decoder1.decode(DemoUser.self, from: userJsonData)<br>    print(user)<br>    // Output: DemoUser(id: &quot;ABCD1528&quot;, name: &quot;Krishna&quot;, email: &quot;kpmobileappdeveloper@gmail.com&quot;)<br>} catch {<br>    print(error)<br>}</pre><h3>Case 3: Combining Custom CodingKey with .convertFromSnakeCase</h3><p>You can combine the convertFromSnakeCase strategy with custom CodingKey mappings for more control over JSON decoding:</p><pre>import Foundation<br><br>struct CustomUser: Codable {<br>    var id: String<br>    var firstName: String<br>    var lastName: String<br>    var email: String<br><br>    enum CodingKeys: String, CodingKey {<br>        case id = &quot;userId&quot;<br>        case firstName<br>        case lastName<br>        case email = &quot;userEmail&quot;<br>    }<br>}<br><br>let customJsonData = &quot;&quot;&quot;<br>{<br>    &quot;user_id&quot;: &quot;ABCD1528&quot;,<br>    &quot;first_name&quot;: &quot;Krishna&quot;,<br>    &quot;last_name&quot;: &quot;Prakash&quot;,<br>    &quot;user_email&quot;: &quot;kpmobileappdeveloper@gmail.com&quot;<br>}<br>&quot;&quot;&quot;.data(using: .utf8)!<br><br>let decoder2 = JSONDecoder()<br>decoder2.keyDecodingStrategy = .convertFromSnakeCase<br><br>do {<br>    let user = try decoder2.decode(CustomUser.self, from: customJsonData)<br>    print(user)<br>    // Output: CustomUser(id: &quot;ABCD1528&quot;, firstName: &quot;Krishna&quot;, lastName: &quot;Prakash&quot;, email: &quot;kpmobileappdeveloper@gmail.com&quot;)<br>} catch {<br>    print(error)<br>}</pre><h3>Case 4: Handling Leading and Trailing Underscores</h3><p>The convertFromSnakeCase strategy does not affect leading or trailing underscores. For example, _first_name is transformed as follows:</p><pre>import Foundation<br><br>struct BasicUser: Codable {<br>    var firstName: String<br>    var lastName: String<br>}<br><br>let detailJsonData = &quot;&quot;&quot;<br>{<br>    &quot;_first_name&quot;: &quot;Krishna&quot;,<br>    &quot;last_name_&quot;: &quot;Prakash&quot;<br>}<br>&quot;&quot;&quot;.data(using: .utf8)!<br><br>let decoder4 = JSONDecoder()<br>decoder4.keyDecodingStrategy = .convertFromSnakeCase<br><br>do {<br>    let user = try decoder4.decode(BasicUser.self, from: detailJsonData)<br>    print(user)<br>    // Output: keyNotFound(CodingKeys(stringValue: &quot;firstName&quot;, intValue: nil), Swift.DecodingError.Context(codingPath: [], debugDescription: &quot;No value associated with key CodingKeys(stringValue: \&quot;firstName\&quot;, intValue: nil) (\&quot;firstName\&quot;).&quot;, underlyingError: nil))<br>} catch {<br>    print(error)<br>}</pre><h3>Test convertFromSnakeCase Expected Key String</h3><p>Here’s how you can visualize the transformation of snake_case keys using the convertFromSnakeCase strategy:</p><p>Feel free to experiment with various snakeCaseKey values to see the resulting transformations.</p><pre>import Foundation<br><br>let snakeCaseKey = &quot;first__name&quot;<br><br>extension JSONDecoder.KeyDecodingStrategy {<br>    static func convertFromSnakeCase(_ key: String) -&gt; String {<br>        guard !key.isEmpty else { return key }<br><br>        let components = key.split(separator: &quot;_&quot;)<br>        let leadingUnderscores = key.prefix(while: { $0 == &quot;_&quot; })<br>        let trailingUnderscores = key.reversed().prefix(while: { $0 == &quot;_&quot; }).reversed()<br>        let capitalizedComponents = components.enumerated().map { index, component in<br>            index == 0 ? component.lowercased() : component.capitalized<br>        }<br>        let joined = capitalizedComponents.joined()<br>        return leadingUnderscores + joined + trailingUnderscores<br>    }<br>}<br><br>let camelCaseKey = JSONDecoder.KeyDecodingStrategy.convertFromSnakeCase(snakeCaseKey)<br>print(camelCaseKey) // Output: &quot;firstName&quot;<br><br>// Input 1: let snakeCaseKey = &quot;_first_name&quot;<br>// Output 1: _firstName<br><br>// Input 2: &quot;_first__name_&quot;<br>// Output 2: _firstName_</pre><p>Sample code:</p><p><a href="https://github.com/kittu4ios/convertFromSnakeCase">https://github.com/kittu4ios/convertFromSnakeCase</a></p><h3>Conclusion</h3><p>The convertFromSnakeCase strategy is a useful tool for handling JSON data with snake_case keys. By combining this strategy with custom CodingKey implementations, you can manage various naming conventions and special cases effectively. Understanding how to handle leading and trailing underscores, along with custom key mappings, allows for more flexible and accurate JSON decoding in your Swift applications.</p><p><strong><em>We’d love to hear your thoughts! Please share your feedback in the comments section, and if you found this article valuable, don’t forget to give it a clap! </em></strong>👏<strong><em> Your support helps us continue to provide useful content. Thank you!</em></strong></p><p>Happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=808bf870b8dc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Master Mobile App Security: Essential Layers and Pro Tips for iOS and Android]]></title>
            <link>https://medium.com/@krishnaprakashn/strengthening-mobile-app-security-essential-layers-and-best-practices-e2faaef31d6e?source=rss-d28ec9c3baf9------2</link>
            <guid isPermaLink="false">https://medium.com/p/e2faaef31d6e</guid>
            <category><![CDATA[mobile-app-security]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[mobile-apps-development]]></category>
            <dc:creator><![CDATA[Krishna Prakash]]></dc:creator>
            <pubDate>Tue, 27 Feb 2024 11:31:16 GMT</pubDate>
            <atom:updated>2024-11-18T17:32:31.997Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*O4XlIulHaTqbf_aPcKIcbw.jpeg" /></figure><p>In today’s world, more and more people are using mobile apps every day. Whether it’s for socializing, shopping, or managing business tasks, mobile apps have become a central part of our lives. But with this increased usage comes a big responsibility: keeping our personal and business information safe.</p><p>Think about all the sensitive data we store on our phones — from personal photos to banking details. App providers must take steps to ensure this information stays secure. After all, there are plenty of hackers out there just waiting to get their hands on it.</p><p>That’s where security measures come in. By implementing strong security measures, app providers can help protect user information from potential threats. Let’s take a closer look at some of these security layers and how they work.</p><p>This article explores the various security layers commonly employed in mobile applications, divided into two main categories: Outbound and Inbound.</p><p><strong>Out-Bound Security Layers</strong></p><p><strong>App Installation</strong>:</p><p>When users install an app, it’s crucial to ensure they do so on secure devices. Avoiding installations on jailbroken or rooted devices is a fundamental step in preventing unauthorized access and tampering with sensitive data.</p><p><em>Example</em>: A banking app should incorporate checks to detect whether a device is jailbroken or rooted before allowing users to access their accounts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*hizsHMvYNlpbTbyq73CgvA.png" /><figcaption>iOS jailbroken device sample alert</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*bOIiagSAbeO5h_XkUYPefg.png" /><figcaption>Android-rooted device sample alert</figcaption></figure><pre>import Foundation<br><br>func isJailbroken() -&gt; Bool {<br>    let jailbrokenPaths = [<br>        &quot;/Applications/Cydia.app&quot;,<br>        &quot;/Library/MobileSubstrate/MobileSubstrate.dylib&quot;,<br>        &quot;/bin/bash&quot;,<br>        &quot;/usr/sbin/sshd&quot;,<br>        &quot;/etc/apt&quot;<br>    ]<br>    for path in jailbrokenPaths {<br>        if FileManager.default.fileExists(atPath: path) {<br>            return true<br>        }<br>    }<br>    return false<br>}</pre><p><strong>Device Management</strong>:</p><p>Granting access to device hardware or web URLs should be done judiciously to minimize potential vulnerabilities. Unnecessary permissions, such as requesting access to location or camera/gallery functionalities, should be avoided unless essential.</p><p><em>Example</em>: A photo editing app should request access to the camera/gallery only when users initiate the image editing process.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p4p-_so0-yHs-A5TdY4Mvg.png" /></figure><p><strong>Mobile Security Audit</strong>:</p><p>Conducting thorough security audits before app release is vital for identifying and addressing potential vulnerabilities. Following standards such as OWASP Mobile Application Security Verification Standard ensures comprehensive security assessment.</p><p><em>Example</em>: Running automated and manual tests to check for vulnerabilities like insecure data storage, insecure communication, or improper session handling.</p><p><strong>Obfuscation</strong>:</p><p>Mobile app obfuscation is a crucial step in enhancing the security of mobile applications. It involves transforming the source code in various ways to make it more challenging for hackers to reverse engineer and understand.</p><p>When we obfuscate the code, we’re essentially making it harder for anyone who tries to peek into the app’s inner workings. This is especially important for apps that handle sensitive data like personal information or financial details.</p><p><strong>How Mobile App Obfuscation Works:</strong></p><ol><li><strong>Changing Names:</strong> One common obfuscation technique is to change the names of variables, classes, and methods in the code. This simple yet effective approach makes it harder for attackers to comprehend the purpose and functionality of different components within the app.</li><li><strong>Removing Unused Code:</strong> Obfuscation also involves removing any unnecessary or unused code from the app. This streamlining process not only reduces the app’s size but also eliminates potential vulnerabilities that attackers could exploit.</li><li><strong>Encrypting the Code:</strong> For added protection, some developers may choose to encrypt portions of the code. This encryption layer makes it extremely difficult for attackers to decipher the code, even if they manage to access it.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/756/1*-sFzmmQAejp2bE3jCIBeKQ.png" /></figure><h3>In-Bound Security Layers</h3><p><strong>Cryptography:</strong></p><ul><li>Cryptographic techniques like encryption and decryption play a pivotal role in securing user data. Utilizing asymmetric or symmetric encryption methods strengthens data protection against unauthorized access.<br><em>Example</em>: Encrypting sensitive user information such as passwords or financial data before storing them in the app’s database.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eRqwQRd5G8Jawjhip8hc2g.png" /></figure><p><strong>Sample Code:</strong></p><pre>import Foundation<br>import CommonCrypto<br><br>func encryptData(_ data: Data, key: Data) -&gt; Data? {<br>    var numBytesEncrypted: size_t = 0<br>    let bufferSize = data.count + kCCBlockSizeAES128<br>    var buffer = Data(count: bufferSize)<br>    <br>    let cryptStatus = data.withUnsafeBytes { dataBytes in<br>        key.withUnsafeBytes { keyBytes in<br>            buffer.withUnsafeMutableBytes { bufferBytes in<br>                CCCrypt(<br>                    CCOperation(kCCEncrypt),<br>                    CCAlgorithm(kCCAlgorithmAES),<br>                    CCOptions(kCCOptionPKCS7Padding),<br>                    keyBytes.baseAddress, kCCKeySizeAES128,<br>                    nil,<br>                    dataBytes.baseAddress, data.count,<br>                    bufferBytes.baseAddress, bufferSize,<br>                    &amp;numBytesEncrypted<br>                )<br>            }<br>        }<br>    }<br>    guard cryptStatus == kCCSuccess else { return nil }<br>    return buffer[..&lt;numBytesEncrypted]<br>}</pre><p><strong>SSL Pinning:</strong></p><ul><li>Implementing SSL certificate pinning enhances the security of communication between the app and its server. By associating a host with its certificate or public key, SSL pinning mitigates the risk of man-in-the-middle attacks.<br><em>Example</em>: Integrating TrustKit SDK for SSL pinning to ensure secure communication between the mobile app and server endpoints.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*6v5HwrNLBoNgBuYfNTrMbw.png" /></figure><pre>class SecureSessionDelegate: NSObject, URLSessionDelegate {<br>    func urlSession(_ session: URLSession, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -&gt; Void) {<br>        guard let serverTrust = challenge.protectionSpace.serverTrust else {<br>            completionHandler(.cancelAuthenticationChallenge, nil)<br>            return<br>        }<br><br>        // Load the pinned certificate from the app bundle<br>        guard let certificatePath = Bundle.main.path(forResource: &quot;mycert&quot;, ofType: &quot;cer&quot;),<br>              let certificateData = try? Data(contentsOf: URL(fileURLWithPath: certificatePath)),<br>              let certificate = SecCertificateCreateWithData(nil, certificateData as CFData) else {<br>            completionHandler(.cancelAuthenticationChallenge, nil)<br>            return<br>        }<br><br>        // Set the pinned certificate as the only trusted anchor<br>        SecTrustSetAnchorCertificates(serverTrust, [certificate] as CFArray)<br>        SecTrustSetAnchorCertificatesOnly(serverTrust, true)<br><br>        // Evaluate the server&#39;s trust<br>        var error: CFError?<br>        let isTrusted = SecTrustEvaluateWithError(serverTrust, &amp;error)<br><br>        if isTrusted {<br>            // Trust evaluation passed, use the credential<br>            let credential = URLCredential(trust: serverTrust)<br>            completionHandler(.useCredential, credential)<br>        } else {<br>            // Trust evaluation failed<br>            print(&quot;SSL pinning failed: \(error?.localizedDescription ?? &quot;Unknown error&quot;)&quot;)<br>            completionHandler(.cancelAuthenticationChallenge, nil)<br>        }<br>    }<br>}<br><br>Usage: <br><br>let delegate = SecureSessionDelegate1()<br>let session = URLSession(configuration: .default, delegate: delegate, delegateQueue: nil)<br><br>if let url = URL(string: &quot;https://secure.example.com/api&quot;) {<br>    var request = URLRequest(url: url)<br>    request.httpMethod = &quot;GET&quot;<br><br>    let task = session.dataTask(with: request) { data, response, error in<br>        if let error = error {<br>            print(&quot;Request failed with error: \(error.localizedDescription)&quot;)<br>        } else {<br>            print(&quot;Request succeeded.&quot;)<br>        }<br>    }<br>    task.resume()<br>}</pre><p><strong>App Transport Security (ATS):</strong></p><ul><li>Leveraging ATS features on Apple platforms enhances privacy and data integrity for all app interactions. Enabling ATS protections and additional security features like Certificate Transparency fortifies app security against external threats.<br><em>Example</em>: Configuring ATS to enforce secure communication protocols and restricting insecure loads for web views.</li></ul><p><strong>Sample Code: Configuring ATS in </strong><strong>Info.plist</strong><br> Add the following to your Info.plist to enforce secure connections:</p><pre>&lt;key&gt;NSAppTransportSecurity&lt;/key&gt;<br>&lt;dict&gt;<br>    &lt;key&gt;NSAllowsArbitraryLoads&lt;/key&gt;<br>    &lt;false/&gt;<br>&lt;/dict&gt;</pre><p><strong>Sensitive Data Handling:</strong></p><ul><li>Adopting best practices for handling sensitive data, such as avoiding hardcoding of app keys and utilizing secure storage mechanisms like keychains, is essential for protecting user information from unauthorized access.<br><em>Example</em>: Storing API keys or authentication tokens securely using cryptographic techniques and keychain services.</li></ul><p>Sample Code:</p><pre>import Foundation<br><br>// Store tokens securely<br>func storeToken(token: String, key: String) {<br>    let keychainQuery: [String: Any] = [<br>        kSecClass as String: kSecClassGenericPassword,<br>        kSecAttrAccount as String: key,<br>        kSecValueData as String: token.data(using: .utf8)!<br>    ]<br><br>    // Check if the item already exists<br>    let status = SecItemAdd(keychainQuery as CFDictionary, nil)<br>    if status == errSecDuplicateItem {<br>        // Update the existing item<br>        let updateQuery: [String: Any] = [<br>            kSecValueData as String: token.data(using: .utf8)!<br>        ]<br>        SecItemUpdate(keychainQuery as CFDictionary, updateQuery as CFDictionary)<br>    } else if status != errSecSuccess {<br>        print(&quot;Error storing token: \(status)&quot;)<br>    }<br>}<br><br>// Retrieve tokens<br>func retrieveToken(key: String) -&gt; String? {<br>    let query: [String: Any] = [<br>        kSecClass as String: kSecClassGenericPassword,<br>        kSecAttrAccount as String: key,<br>        kSecReturnData as String: kCFBooleanTrue!,<br>        kSecMatchLimit as String: kSecMatchLimitOne<br>    ]<br>    var result: AnyObject?<br>    let status = SecItemCopyMatching(query as CFDictionary, &amp;result)<br>    if status == errSecSuccess, let data = result as? Data {<br>        return String(data: data, encoding: .utf8)<br>    } else {<br>        print(&quot;Error retrieving token: \(status)&quot;)<br>        return nil<br>    }<br>}</pre><p><strong>Snapshot: Protecting User Privacy</strong></p><p>Have you ever considered what happens to your app’s screen when you switch to another app? It turns out, there’s a potential risk of exposing sensitive information to prying eyes. That’s where the concept of a “snapshot” comes in handy.</p><p>Imagine you’re using a health-related app to manage your medical information. You might be entering details about your health conditions, medications, or appointments. Now, what if you suddenly switch to another app without closing the health app first? There’s a chance that a quick glance from someone nearby could reveal your personal health data.</p><p>To prevent such accidental exposure of sensitive information, it’s recommended to implement a snapshot feature in your app. When a user tries to switch or transition to another app, your app can display a blurred screen or snapshot instead of showing its actual content.</p><p>This simple yet effective measure adds an extra layer of privacy protection, ensuring that users’ personal information remains confidential. Especially in domains like healthcare, and banking where the data being handled is particularly sensitive, such precautions are crucial.</p><p>So, next time you’re developing a mobile app, remember to include a snapshot feature to safeguard your users’ privacy and maintain their trust in your app’s security. After all, protecting personal information is not just a priority; it’s a responsibility.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eeEqMIH1xu8ZC_Rg0NWcxQ.png" /><figcaption>Sample image</figcaption></figure><h4>Evaluating Third-Party Libraries for Security</h4><p>When it comes to building robust mobile applications, the integration of third-party libraries can significantly enhance functionality and streamline development. However, it’s crucial to tread carefully and thoroughly evaluate these libraries for potential security vulnerabilities.</p><p>Importance of Security Assessment:</p><p>Conducting a comprehensive security assessment of third-party libraries is paramount to mitigating risks and safeguarding user data. Here’s why:</p><ul><li>Preventing Exploits: By scrutinizing libraries for security vulnerabilities, you can identify and mitigate potential exploits that could compromise the security of your app and its users.</li><li>Ensuring Compliance: Verifying that third-party libraries adhere to necessary permissions and security protocols is essential for maintaining compliance with industry standards and regulations.</li></ul><h4>Example: Security Assessment Process</h4><p>Let’s consider an example scenario where you’re developing a mobile app and integrating various third-party libraries. Here’s how you can conduct a security assessment:</p><ul><li><strong>Research and Analysis:</strong> Thoroughly research each third-party library under consideration. Evaluate its reputation, documentation, and community support. Look for any reported security issues or updates.</li><li><strong>Permissions and Security Protocols:</strong> Review the permissions required by the library and ensure they align with your app’s intended functionality. Verify that the library implements security protocols such as HTTPS for network communication.</li><li><strong>Code Review and Testing:</strong> Dive into the library’s source code to assess its security practices. Look for secure coding practices, encryption methods, and vulnerability mitigation strategies. Perform rigorous testing to uncover any potential weaknesses.</li><li><strong>Monitoring and Updates:</strong> Stay vigilant by continuously monitoring for any reported security vulnerabilities or updates related to the third-party libraries used in your app. Promptly apply patches or updates to mitigate emerging threats.</li></ul><p><strong>Scramble Keypad:</strong></p><p>Adding a scrambled keypad for entering sensitive information like PIN or CVV codes can significantly enhance security. This feature jumbles the layout of numbers, making it harder for potential attackers to decipher the input pattern visually. It provides users with peace of mind knowing their data is better protected against unauthorized access. By incorporating this extra layer of security, apps demonstrate a commitment to prioritizing user privacy and safety, fostering trust among users.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*uE7qi1kibQhtifKw8QpnTg.png" /></figure><p>By incorporating these comprehensive security layers and best practices into mobile app development processes, providers can significantly mitigate security risks and safeguard user data effectively. Prioritizing security not only instills trust and confidence among users but also ensures compliance with regulatory standards and industry best practices.</p><p>Happy Coding !!!!<br>Found this post useful? Kindly tap the 👏 button below! :)</p><p><strong>References:</strong></p><ul><li>Jailbroken Device: <a href="https://www.appknox.com/blog/ios-jailbreak-detection-bypass">https://www.appknox.com/blog/ios-jailbreak-detection-bypass</a></li><li>Security Audit: <a href="https://github.com/OWASP/owasp-masvs">https://github.com/OWASP/owasp-masvs</a></li><li>Cryptography: <a href="https://mobile-security.gitbook.io/mobile-security-testing-guide/general-mobile-app-testing-guide/0x04g-testing-cryptography">https://mobile-security.gitbook.io/mobile-security-testing-guide/general-mobile-app-testing-guide/0x04g-testing-cryptography</a></li><li>SSL Pinning: <a href="https://owasp.org/www-community/controls/Certificate_and_Public_Key_Pinning">https://owasp.org/www-community/controls/Certificate_and_Public_Key_Pinning</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e2faaef31d6e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>