<?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 Igor Pak on Medium]]></title>
        <description><![CDATA[Stories by Igor Pak on Medium]]></description>
        <link>https://medium.com/@ipak.tulane?source=rss-62d93c89df20------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*eG7ZVxxExvqb_lhwGzEhug.jpeg</url>
            <title>Stories by Igor Pak on Medium</title>
            <link>https://medium.com/@ipak.tulane?source=rss-62d93c89df20------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 17:21:11 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ipak.tulane/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[Deferred Deep Linking: AppsFlyer vs. Facebook]]></title>
            <link>https://medium.com/@ipak.tulane/deferred-deep-linking-appsflyer-vs-facebook-a717a53d9238?source=rss-62d93c89df20------2</link>
            <guid isPermaLink="false">https://medium.com/p/a717a53d9238</guid>
            <category><![CDATA[firebase]]></category>
            <category><![CDATA[deeplink]]></category>
            <category><![CDATA[appsflyer]]></category>
            <category><![CDATA[facebook]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Igor Pak]]></dc:creator>
            <pubDate>Tue, 25 Jun 2024 10:47:00 GMT</pubDate>
            <atom:updated>2024-06-25T10:49:24.887Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Deferred deep linking is a powerful tool for mobile apps, enabling users to be directed to specific content within the app after installation. This streamlines the user experience and enhances the effectiveness of marketing campaigns. This article explores deferred deep linking in iOS projects, comparing the services offered by AppsFlyer and Facebook (both considered to replace Firebase Dynamic Links to be deprecated on August 25, 2025).</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mAuzhdFWcFuPGoZeIcCJKg.jpeg" /></figure><p><strong>Firebase Dynamic Links (FDL) Deprecation (August 25, 2025)</strong></p><p>Firebase announced the deprecation of FDL deferred links on August 25, 2023. While existing links will continue to work until the service shuts down entirely on August 25, 2025, creating new deferred links or reconnecting existing ones is no longer possible.</p><p>Due to this limitation, FDL is not a suitable option for new projects. This is why we’ve excluded FDL from our comparison of deferred deep-linking providers.</p><p><strong>AppsFlyer vs. Facebook: A Head-to-Head Comparison</strong></p><p>Here’s a breakdown of how AppsFlyer and Facebook approach deferred deep linking:</p><p><strong>AppsFlyer</strong></p><p><strong>Focus:</strong> Comprehensive marketing and attribution.</p><p><strong>Features:</strong> Attribution analytics, conversion tracking, user-level analytics, fraud protection, in-app attribution, post-install event tracking, and multi-channel attribution.</p><p><strong>Target Apps:</strong> Apps focused on marketing and user acquisition.</p><p><strong>Strengths:</strong></p><ul><li>Robust analytics and attribution data across platforms.</li><li>Flexibility for future expansion beyond Facebook.</li><li>Integration with various marketing platforms.</li></ul><p><strong>Weaknesses:</strong></p><ul><li>Requires understanding of MMP (Mobile Measurement Partner) concepts.</li><li>SDK overhead adds to app size and complexity.</li><li>Freemium limitations may necessitate paid plans for growth.</li></ul><p><strong>Pricing:</strong> Freemium model with limited features, paid plans for advanced features.</p><p><strong>Data Privacy:</strong> GDPR and CCPA compliant, anonymized data by default.</p><p><strong>Ease of Use:</strong> Moderate learning curve, comprehensive SDK documentation.</p><p><strong>Facebook</strong></p><p><strong>Focus:</strong> Facebook Ads attribution and user experience personalization.</p><p><strong>Features:</strong> Attribution analytics, conversion tracking, user-level analytics, audience targeting, campaign management, and retargeting.</p><p><strong>Target Apps:</strong> Apps heavily reliant on Facebook advertising.</p><p><strong>Strengths:</strong></p><ul><li>Simple integration if Facebook SDK already exists.</li><li>Seamless integration with Facebook advertising.</li><li>Cost-effective for Facebook-centric advertising.</li></ul><p><strong>Weaknesses:</strong></p><ul><li>Limited to Facebook Ads attribution (no app invites allowed).</li><li>Data privacy concerns due to reliance on Facebook.</li><li>Deep link data analysis primarily within Facebook platforms.</li></ul><p><strong>Pricing:</strong> Free for basic deep linking, and paid advertising within Facebook.</p><p><strong>Ease of Use:</strong> Low learning curve if familiar with the Facebook Ads platform.</p><p><strong>Choosing the Right Provider</strong></p><p>The best choice depends on your app’s marketing strategy and technical setup. Here’s a quick guide:</p><ul><li><strong>Choose AppsFlyer:</strong> If you need comprehensive user acquisition and in-app analytics, detailed attribution data, and flexibility beyond Facebook.</li><li><strong>Choose Facebook:</strong> If you primarily rely on Facebook Ads for user acquisition and want a simple integration with your existing Facebook SDK setup.</li></ul><p><strong>Conclusion</strong></p><p>This article provides a starting point for choosing a deferred deep linking provider for your iOS project. AppsFlyer offers a robust solution for diverse marketing needs, while Facebook caters to apps heavily invested in Facebook Ads. Consider your specific requirements and weigh the factors mentioned above to make an informed decision.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a717a53d9238" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Essential Questions to Ace Your Build System Interview]]></title>
            <link>https://medium.com/@ipak.tulane/essential-questions-to-ace-your-build-system-interview-fd2f8a7c2b7d?source=rss-62d93c89df20------2</link>
            <guid isPermaLink="false">https://medium.com/p/fd2f8a7c2b7d</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[interview]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[build]]></category>
            <dc:creator><![CDATA[Igor Pak]]></dc:creator>
            <pubDate>Sun, 19 May 2024 12:25:50 GMT</pubDate>
            <atom:updated>2024-05-19T12:25:50.407Z</atom:updated>
            <content:encoded><![CDATA[<p>If you’re aiming to join a top-notch mobile DevOps team, you’ll need to be prepared for a rigorous interview process that dives deep into build systems and optimization. Here are some essential questions, insights, and code examples that can help you succeed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ca8Ini-TP7LN6Z0YgLIeCg.jpeg" /></figure><h3>Understanding the Basics</h3><h4>1. Static Libraries vs. Dynamic Libraries</h4><p>Question: What is the difference between static and dynamic libraries?</p><p>Answer: Static libraries (.a files) are incorporated into the final executable during compile time, resulting in a larger binary size but improved performance since no runtime linking is required. Dynamic libraries (.dylib, .so files), on the other hand, are linked at runtime, which keeps the executable smaller and allows multiple programs to share the library. However, this can increase the startup time due to the additional loading step.</p><p>Creating a Static Library:</p><ol><li>Create a new Xcode project for a static library.</li><li>Add your source files.</li><li>Build the project to generate the .a file.</li></ol><p>Using a Static Library:</p><pre>// Import the header file for the static library<br>#import &quot;MyStaticLibrary.h&quot;<br><br>func useStaticLibrary() {<br>    let result = MyStaticLibrary.someFunction()<br>    print(result)<br>}</pre><p>Creating a Dynamic Library:</p><ol><li>Create a new Xcode project for a dynamic library.</li><li>Add your source files.</li><li>Build the project to generate the .dylib file.</li></ol><p>Using a Dynamic Library:</p><pre>// Import the module for the dynamic library<br>import MyDynamicLibrary<br><br>func useDynamicLibrary() {<br>    let result = MyDynamicLibrary.someFunction()<br>    print(result)<br>}</pre><h4>2. What is a Scheme in Xcode?</h4><p>Question: What is a scheme in the context of Xcode?</p><p>Answer: A scheme in Xcode defines a collection of settings and actions related to building, testing, profiling, debugging, and archiving your application. It specifies which targets to build, the build configurations to use, and additional settings like launch arguments and environment variables.</p><p>Code Example: Custom Scheme Configuration</p><ol><li>Open your project in Xcode.</li><li>Go to Product &gt; Scheme &gt; Manage Schemes.</li><li>Add a new scheme or edit an existing one.</li><li>Configure the build, test, profile, analyze, and archive actions.</li></ol><pre>// Example of using a custom scheme to set environment variables<br>#if DEBUG<br>    let apiEndpoint = &quot;https://api.dev.example.com&quot;<br>#else<br>    let apiEndpoint = &quot;https://api.example.com&quot;<br>#endif</pre><h4>3. xcodeproj vs. xcworkspace</h4><p>Question: What is the difference between xcodeproj and xcworkspace?</p><p>Answer: An .xcodeproj file is an Xcode project file that contains the build settings, configurations, and the list of source files. An .xcworkspace file is an Xcode workspace, which can contain multiple .xcodeproj files. Workspaces are useful for managing complex projects with multiple dependencies, making it easier to coordinate builds across different projects.</p><p>Code Example: Using .xcworkspacewith CocoaPods</p><ol><li>Install CocoaPods if you haven’t already:</li></ol><pre>sudo gem install cocoapods</pre><p>2. Create a Podfile in your project directory:</p><pre>platform :ios, &#39;14.0&#39;<br><br>target &#39;MyApp&#39; do<br>  use_frameworks!<br><br>  pod &#39;Alamofire&#39;<br>end</pre><p>3. Run pod install to create the .xcworkspace file:</p><pre>pod install</pre><p>4. Open the .xcworkspace file in Xcode:</p><pre>open MyApp.xcworkspace</pre><h3>Delving Deeper</h3><h4>4. Causes of Slow Build Times</h4><p>Question: What could cause a slow build in Xcode?</p><p>Answer: Several factors can contribute to slow build times in Xcode:</p><ul><li>Excessive Dependencies: Overly complex dependency trees can cause extensive recompilation.</li><li>Large Codebase: A vast number of source files or complex build schemes can slow down the process.</li><li>Outdated Tools and Settings: Using inefficient or outdated build settings and tools can degrade performance.</li><li>Inefficient Caching: Poor cache management of intermediate build products can lead to redundant compilations.</li><li>Pre-build/Post-build Tasks: Heavy tasks during pre-build or post-build phases can add significant time.</li><li>Hardware Limitations: Insufficient processing power or memory on build servers or local machines.</li></ul><p>Code Example: Enabling and Analyzing Build Logs</p><p>To enable verbose build logs, add the following to your Build Settings under Other Swift Flags:</p><pre>-Xfrontend -debug-time-function-bodies</pre><p>This will output the time taken by each function during compilation to the build log.</p><h4>5. Disconnecting a Mac Mini via SSH</h4><p>Question: How do you disconnect a Mac Mini via SSH?</p><p>Answer: To disconnect a Mac Mini via SSH, you can use the following command:</p><pre>ssh user@macmini<br>sudo shutdown -h now</pre><p>This command will halt all processes and shut down the system. Ensure that all important tasks are completed before executing this command, as it will power off the machine immediately.</p><h4>6. Identifying Build Slowdowns</h4><p>Question: How do you identify the reasons for build slowdowns?</p><p>Answer: To identify build slowdowns, consider the following approaches:</p><ul><li>Enable Verbose Logging: Use verbose mode in Xcode to get detailed output of each build step.</li><li>Profiling Tools: Utilize Xcode Instruments or other profiling tools to analyze the time spent on different build phases.</li><li>Build Logs: Examine build logs for warnings and errors that might indicate inefficiencies.</li><li>Dependency Analysis: Review and optimize dependencies to reduce unnecessary recompilations.</li><li>Caching Strategies: Implement effective caching solutions such as distcc or ccache to speed up build times.</li><li>Hardware Resources: Ensure adequate hardware resources to support build operations efficiently.</li></ul><p>Code Example: Using Xcode Instruments for Profiling</p><ol><li>Build and run your app in Xcode.</li><li>Go to Product &gt; Profile to open Xcode Instruments.</li><li>Select the Time Profiler template.</li><li>Start recording and interact with your app to gather data.</li><li>Analyze the recorded data to identify slow functions and bottlenecks.</li></ol><h3>Conclusion</h3><p>Preparing for a build system interview requires a solid understanding of both fundamental and advanced concepts. By familiarizing yourself with the questions, answers, and code examples above, you’ll be better equipped to tackle the challenges and demonstrate your expertise. Whether it’s differentiating between static and dynamic libraries or optimizing build times, these insights will help you stand out in your next interview.</p><p>Remember, every interview is a learning experience. Even if you don’t pass, the knowledge you gain and the feedback you receive can propel you forward in your career. Good luck!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fd2f8a7c2b7d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[UserDefaults: Data Management in Swift iOS Apps]]></title>
            <link>https://medium.com/@ipak.tulane/userdefaults-data-management-in-swift-ios-apps-fc6f219d13d8?source=rss-62d93c89df20------2</link>
            <guid isPermaLink="false">https://medium.com/p/fc6f219d13d8</guid>
            <category><![CDATA[datamanager]]></category>
            <category><![CDATA[userdefaults]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[crud]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Igor Pak]]></dc:creator>
            <pubDate>Thu, 25 Apr 2024 17:41:33 GMT</pubDate>
            <atom:updated>2024-04-25T17:41:33.849Z</atom:updated>
            <content:encoded><![CDATA[<p><em>In iOS app development, managing data efficiently is paramount for creating a seamless user experience. UserDefaults, a simple key-value storage mechanism provided by Apple, offers a convenient solution for storing small amounts of data, such as user preferences and settings. In this article, we’ll explore how to implement a storage manager following the CRUD (Create, Read, Update, Delete) approach using UserDefaults in Swift.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0toTwvyMhcraIwFPtajpYw.jpeg" /></figure><h4>Understanding UserDefaults</h4><p>UserDefaults provides an interface to interact with user preferences and application settings. It allows developers to store and retrieve data using key-value pairs, making it suitable for storing small amounts of non-sensitive data. UserDefaults data persists between app launches and is accessible across different sessions.</p><h4>Implementing a Storage Manager with UserDefaults</h4><p>Let’s dive into implementing a storage manager class using UserDefaults to perform CRUD operations on our data model.</p><pre>import Foundation<br><br>struct Item: Codable {<br>    let id: String<br>    var name: String<br>    var description: String<br>}<br><br>class StorageManager {<br>    // UserDefaults key<br>    private let userDefaultsKey = &quot;items&quot;<br>    <br>    // MARK: - CRUD Operations<br>    <br>    // Create<br>    func addItem(_ item: Item) {<br>        var items = getAllItems()<br>        items.append(item)<br>        saveItems(items)<br>    }<br>    <br>    // Read<br>    func getAllItems() -&gt; [Item] {<br>        guard let data = UserDefaults.standard.data(forKey: userDefaultsKey) else {<br>            return []<br>        }<br>        do {<br>            let items = try JSONDecoder().decode([Item].self, from: data)<br>            return items<br>        } catch {<br>            print(&quot;Error decoding items: \(error.localizedDescription)&quot;)<br>            return []<br>        }<br>    }<br>    <br>    // Update<br>    func updateItem(_ updatedItem: Item) {<br>        var items = getAllItems()<br>        if let index = items.firstIndex(where: { $0.id == updatedItem.id }) {<br>            items[index] = updatedItem<br>            saveItems(items)<br>        }<br>    }<br>    <br>    // Delete<br>    func deleteItem(withID id: String) {<br>        var items = getAllItems()<br>        items.removeAll(where: { $0.id == id })<br>        saveItems(items)<br>    }<br>    <br>    // MARK: - Helper methods<br>    <br>    private func saveItems(_ items: [Item]) {<br>        do {<br>            let data = try JSONEncoder().encode(items)<br>            UserDefaults.standard.set(data, forKey: userDefaultsKey)<br>        } catch {<br>            print(&quot;Error encoding items: \(error.localizedDescription)&quot;)<br>        }<br>    }<br>}</pre><h4>In this implementation:</h4><ul><li>We define a StorageManager class with methods for adding, retrieving, updating, and deleting items.</li><li>The Item struct represents the data model we want to store, conforming to Codable to facilitate encoding and decoding.</li><li>The userDefaultsKey is the key used to store items in UserDefaults.</li><li>The addItem method adds a new item to the existing list of items.</li><li>The getAllItems method retrieves all items stored in UserDefaults.</li><li>The updateItem method updates an existing item with new data.</li><li>The deleteItem method removes an item with a specified ID.</li><li>Helper methods are provided to encode and decode items from UserDefaults.</li></ul><h4>Conclusion</h4><p>In conclusion, UserDefaults offers a straightforward and efficient solution for storing and managing small amounts of data in Swift iOS apps. By implementing a storage manager following the CRUD approach, developers can easily interact with UserDefaults to perform common data operations. While UserDefaults is suitable for simple data storage requirements, consider using CoreData or other persistence frameworks for more complex data management needs. Happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fc6f219d13d8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Data Management in iOS Apps with CoreData]]></title>
            <link>https://medium.com/@ipak.tulane/data-management-in-ios-apps-with-coredata-3cc7b51aa518?source=rss-62d93c89df20------2</link>
            <guid isPermaLink="false">https://medium.com/p/3cc7b51aa518</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[datamanager]]></category>
            <category><![CDATA[storage]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[core-data]]></category>
            <dc:creator><![CDATA[Igor Pak]]></dc:creator>
            <pubDate>Thu, 25 Apr 2024 17:30:38 GMT</pubDate>
            <atom:updated>2024-04-25T17:30:38.738Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Data management is at the heart of every iOS app, and choosing the right storage solution is crucial for building robust and scalable applications. CoreData, Apple’s powerful and feature-rich framework, provides developers with the tools they need to efficiently manage data. In this comprehensive guide, we’ll explore how to leverage CoreData to implement a storage manager following the CRUD (Create, Read, Update, Delete) approach in Swift.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p9H9e2KL3W-0_msedJx22g.jpeg" /></figure><h4>Setting Up CoreData</h4><p>Before diving into CoreData’s intricacies, let’s first set up our project to use CoreData.</p><ol><li>Create a CoreData Model: Start by creating a new CoreData model file in Xcode (e.g., DataModel.xcdatamodeld). Define your data model by adding entities and attributes using the visual editor.</li><li>Generate NSManagedObject Subclasses: Once your data model is defined, generate NSManagedObject subclasses for your entities. Xcode can automatically generate these subclasses for you based on your data model.</li><li>Initialize the CoreData Stack: In your app’s AppDelegate or a dedicated CoreData stack class, initialize the CoreData stack by loading the persistent store and providing access to the managed object context.</li></ol><h4>Implementing the Storage Manager</h4><p>Now that we have CoreData set up in our project, let’s create a storage manager to perform CRUD operations on our data.</p><pre>import CoreData<br><br>class CoreDataStack {<br>    static let shared = CoreDataStack()<br>    <br>    lazy var persistentContainer: NSPersistentContainer = {<br>        let container = NSPersistentContainer(name: &quot;DataModel&quot;)<br>        container.loadPersistentStores(completionHandler: { (storeDescription, error) in<br>            if let error = error as NSError? {<br>                fatalError(&quot;Unresolved error \(error), \(error.userInfo)&quot;)<br>            }<br>        })<br>        return container<br>    }()<br>    <br>    var viewContext: NSManagedObjectContext {<br>        return persistentContainer.viewContext<br>    }<br>    <br>    func saveContext() {<br>        let context = persistentContainer.viewContext<br>        if context.hasChanges {<br>            do {<br>                try context.save()<br>            } catch {<br>                let nserror = error as NSError<br>                fatalError(&quot;Unresolved error \(nserror), \(nserror.userInfo)&quot;)<br>            }<br>        }<br>    }<br>}<br><br>class StorageManager {<br>    // MARK: - CRUD Operations<br>    <br>    // Create<br>    func addItem(name: String, description: String) {<br>        let context = CoreDataStack.shared.viewContext<br>        let newItem = Item(context: context)<br>        newItem.name = name<br>        newItem.description = description<br>        CoreDataStack.shared.saveContext()<br>    }<br>    <br>    // Read<br>    func getAllItems() -&gt; [Item] {<br>        let context = CoreDataStack.shared.viewContext<br>        let fetchRequest: NSFetchRequest&lt;Item&gt; = Item.fetchRequest()<br>        do {<br>            let items = try context.fetch(fetchRequest)<br>            return items<br>        } catch {<br>            print(&quot;Error fetching items: \(error.localizedDescription)&quot;)<br>            return []<br>        }<br>    }<br>    <br>    // Update<br>    func updateItem(item: Item, newName: String, newDescription: String) {<br>        item.name = newName<br>        item.description = newDescription<br>        CoreDataStack.shared.saveContext()<br>    }<br>    <br>    // Delete<br>    func deleteItem(item: Item) {<br>        let context = CoreDataStack.shared.viewContext<br>        context.delete(item)<br>        CoreDataStack.shared.saveContext()<br>    }<br>}</pre><h4>Explanation</h4><ul><li>We create a CoreDataStack class to manage the CoreData stack, including loading the persistent store and providing access to the managed object context.</li><li>The StorageManager class provides methods for adding, retrieving, updating, and deleting items.</li><li>The addItem method creates a new Item entity and saves it to the CoreData store.</li><li>The getAllItems method fetches all Item entities from the CoreData store.</li><li>The updateItem method updates the name and description of an existing Item.</li><li>The deleteItem method deletes a specific Item from the CoreData store.</li></ul><h4>Conclusion</h4><p>CoreData offers a powerful and efficient way to manage data in iOS apps. By following the CRUD approach and leveraging CoreData’s capabilities, developers can build robust and scalable applications with ease. Whether you’re building a simple to-do list app or a complex data-driven application, CoreData is your go-to solution for data management in iOS development. So, go ahead and harness the full potential of CoreData in your next project!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3cc7b51aa518" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Manage Data Storage in iOS Apps with Realm]]></title>
            <link>https://medium.com/@ipak.tulane/manage-data-storage-in-ios-apps-with-realm-27b3af71e2a2?source=rss-62d93c89df20------2</link>
            <guid isPermaLink="false">https://medium.com/p/27b3af71e2a2</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[datamanager]]></category>
            <category><![CDATA[storage]]></category>
            <category><![CDATA[realm]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Igor Pak]]></dc:creator>
            <pubDate>Thu, 25 Apr 2024 17:20:09 GMT</pubDate>
            <atom:updated>2024-04-25T17:20:09.763Z</atom:updated>
            <content:encoded><![CDATA[<p><em>In the realm of iOS app development, data management is a fundamental aspect that developers constantly grapple with. Whether it’s storing user preferences, managing user-generated content, or handling complex data structures, having a robust and efficient storage solution is crucial. Enter Realm, a powerful and flexible alternative to CoreData. In this article, we’ll explore how to harness the capabilities of Realm to implement a storage manager following the CRUD (Create, Read, Update, Delete) approach in Swift.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eiXe2u_2Co8mYYXKIO0syQ.jpeg" /></figure><h4>Setting Up Realm</h4><p>Before we delve into the nitty-gritty of CRUD operations with Realm, let’s ensure we have it set up in our project. Realm can be integrated into your project manually or through package managers like CocoaPods, Carthage, or Swift Package Manager (SPM). Once integrated, we’re ready to define our data model and initialize Realm.</p><h4>Defining the Data Model</h4><p>In our example, let’s consider a simple data model representing items in a list. We’ll create an Item class that subclasses Object, Realm&#39;s base class for data models.</p><pre>import RealmSwift<br><br>class Item: Object {<br>    @Persisted var id = UUID().uuidString<br>    @Persisted var name = &quot;&quot;<br>    @Persisted var description = &quot;&quot;<br>}</pre><p>Here, we define an Item class with properties representing the item&#39;s ID, name, and description. Using @Persisted property wrappers ensures that these properties are managed by Realm.</p><h4>Implementing the Storage Manager</h4><p>With our data model in place, let’s create a StorageManager class responsible for CRUD operations using Realm.</p><pre>import RealmSwift<br><br>class StorageManager {<br>    // MARK: - CRUD Operations<br>    <br>    // Create<br>    func addItem(name: String, description: String) {<br>        let realm = try! Realm()<br>        let newItem = Item()<br>        newItem.name = name<br>        newItem.description = description<br>        try! realm.write {<br>            realm.add(newItem)<br>        }<br>    }<br>    <br>    // Read<br>    func getAllItems() -&gt; Results&lt;Item&gt; {<br>        let realm = try! Realm()<br>        return realm.objects(Item.self)<br>    }<br>    <br>    // Update<br>    func updateItem(item: Item, newName: String, newDescription: String) {<br>        let realm = try! Realm()<br>        try! realm.write {<br>            item.name = newName<br>            item.description = newDescription<br>        }<br>    }<br>    <br>    // Delete<br>    func deleteItem(item: Item) {<br>        let realm = try! Realm()<br>        try! realm.write {<br>            realm.delete(item)<br>        }<br>    }<br>}</pre><p>In this StorageManager class:</p><ul><li>We provide methods for adding, retrieving, updating, and deleting items.</li><li>The addItem method creates a new Item object, sets its properties, and saves it to the Realm database.</li><li>The getAllItems method retrieves all Item objects from the Realm database.</li><li>The updateItem method updates the properties of an existing Item object.</li><li>The deleteItem method deletes a specific Item object from the Realm database.</li></ul><h4>Conclusion</h4><p>In this article, we’ve explored how to leverage Realm to implement a robust storage manager following the CRUD approach in iOS app development. Realm offers a seamless and efficient way to manage data, allowing developers to focus on building great user experiences without worrying about the intricacies of data storage. By integrating Realm into your projects, you can elevate your app’s performance and scalability while maintaining a clean and maintainable codebase. So, why wait? Dive into the world of Realm and unlock the full potential of your iOS apps!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=27b3af71e2a2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Keychain: A CRUD Approach to Secure Data Storage in iOS Apps]]></title>
            <link>https://medium.com/@ipak.tulane/keychain-a-crud-approach-to-secure-data-storage-in-ios-apps-bb13518cc9e2?source=rss-62d93c89df20------2</link>
            <guid isPermaLink="false">https://medium.com/p/bb13518cc9e2</guid>
            <category><![CDATA[keychain]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[crud]]></category>
            <dc:creator><![CDATA[Igor Pak]]></dc:creator>
            <pubDate>Thu, 25 Apr 2024 17:09:00 GMT</pubDate>
            <atom:updated>2024-04-25T17:33:40.479Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Data security is paramount in modern app development, especially when handling sensitive information such as user credentials or tokens. While there are various options for data storage on iOS, the Keychain stands out as a secure and reliable solution. In this article, we’ll explore how to implement a storage manager following the CRUD (Create, Read, Update, Delete) approach using the Keychain in Swift.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tWl3ent4uPHPiF3qRB6HWg.jpeg" /></figure><h4>Understanding the Keychain</h4><p>The Keychain is a secure storage mechanism provided by Apple for storing sensitive data such as passwords, cryptographic keys, and certificates. It encrypts data and ensures that only authorized apps can access it. Keychain items are associated with a service identifier and an account identifier, making them uniquely identifiable and secure.</p><h4>Implementing CRUD Operations with the Keychain</h4><p>To demonstrate the CRUD operations using the Keychain, we’ll create a StorageManager class and a Item struct to represent the data model. Let&#39;s dive into the implementation:</p><pre>import Foundation<br>import Security<br><br>struct Item {<br>    let id: String<br>    let name: String<br>    let description: String<br>}<br><br>class StorageManager {<br>    // Keychain service identifier<br>    private let serviceIdentifier = &quot;com.example.app.items&quot;<br>    <br>    // MARK: - CRUD Operations<br>    <br>    // Create<br>    func addItem(_ item: Item) {<br>        guard let data = try? JSONEncoder().encode(item) else {<br>            return<br>        }<br>        let query: [String: Any] = [<br>            kSecClass as String: kSecClassGenericPassword,<br>            kSecAttrService as String: serviceIdentifier,<br>            kSecAttrAccount as String: item.id,<br>            kSecValueData as String: data<br>        ]<br>        SecItemAdd(query as CFDictionary, nil)<br>    }<br>    <br>    // Read<br>    func getItem(withId id: String) -&gt; Item? {<br>        let query: [String: Any] = [<br>            kSecClass as String: kSecClassGenericPassword,<br>            kSecAttrService as String: serviceIdentifier,<br>            kSecAttrAccount as String: id,<br>            kSecReturnData as String: true,<br>            kSecMatchLimit as String: kSecMatchLimitOne<br>        ]<br>        var item: CFTypeRef?<br>        let status = SecItemCopyMatching(query as CFDictionary, &amp;item)<br>        guard status == errSecSuccess, let data = item as? Data, let loadedItem = try? JSONDecoder().decode(Item.self, from: data) else {<br>            return nil<br>        }<br>        return loadedItem<br>    }<br>    <br>    // Update<br>    func updateItem(_ item: Item) {<br>        guard let data = try? JSONEncoder().encode(item) else {<br>            return<br>        }<br>        let query: [String: Any] = [<br>            kSecClass as String: kSecClassGenericPassword,<br>            kSecAttrService as String: serviceIdentifier,<br>            kSecAttrAccount as String: item.id<br>        ]<br>        let attributes: [String: Any] = [<br>            kSecValueData as String: data<br>        ]<br>        SecItemUpdate(query as CFDictionary, attributes as CFDictionary)<br>    }<br>    <br>    // Delete<br>    func deleteItem(withId id: String) {<br>        let query: [String: Any] = [<br>            kSecClass as String: kSecClassGenericPassword,<br>            kSecAttrService as String: serviceIdentifier,<br>            kSecAttrAccount as String: id<br>        ]<br>        SecItemDelete(query as CFDictionary)<br>    }<br>}</pre><h4>Explanation</h4><ol><li>Create Operation (addItem): We encode the Item object into data using JSONEncoder and add it to the Keychain as a generic password item with a service identifier and an account identifier.</li><li>Read Operation (getItem): We construct a query to retrieve the item from the Keychain based on its account identifier. If found, we decode the data into an Item object using JSONDecoder.</li><li>Update Operation (updateItem): We encode the updated Item object into data and update the existing Keychain item based on its account identifier.</li><li>Delete Operation (deleteItem): We construct a query to delete the item from the Keychain based on its account identifier.</li></ol><h4>Conclusion</h4><p>In this article, we’ve explored how to implement a storage manager following the CRUD approach using the Keychain in iOS app development. By leveraging the Keychain, developers can securely store sensitive data and ensure that it remains protected from unauthorized access. Implementing CRUD operations with the Keychain provides a robust foundation for building secure and reliable iOS apps.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bb13518cc9e2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating Custom Charts in iOS Using Swift]]></title>
            <link>https://medium.com/@ipak.tulane/creating-custom-charts-in-ios-using-swift-959551e1f7eb?source=rss-62d93c89df20------2</link>
            <guid isPermaLink="false">https://medium.com/p/959551e1f7eb</guid>
            <category><![CDATA[custom-views]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[charts]]></category>
            <category><![CDATA[uikit]]></category>
            <category><![CDATA[swift]]></category>
            <dc:creator><![CDATA[Igor Pak]]></dc:creator>
            <pubDate>Thu, 25 Apr 2024 07:46:30 GMT</pubDate>
            <atom:updated>2024-04-25T07:54:33.248Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Charts are indispensable tools for visualizing data in mobile applications. While iOS provides some built-in charting capabilities through frameworks like </em><em>UIKit and </em><em>Core Graphics, creating custom charts allows for more flexibility and customization. In this tutorial, we&#39;ll explore how to create three types of custom charts: a classic Pie Chart, a Doughnut Chart with a hollow center, and a Circular Chart with arcs.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/615/1*88Ymyb0W4aGo3S4x9Wlhvg.png" /></figure><h3>Pie Chart (Classic Variant)</h3><p>Let’s start by creating a classic Pie Chart. We’ll represent data as slices of a circular pie, where each slice corresponds to a data category. Here’s how we can implement it:</p><pre>import UIKit<br><br>class PieChartViewController: UIViewController {<br>    <br>    // MARK: - Properties<br>    <br>    var circularView: PieChartCircular!<br>    <br>    // MARK: - View Lifecycle<br>    <br>    override func viewDidLoad() {<br>        super.viewDidLoad()<br>        view.backgroundColor = .systemBackground<br>        <br>        setupCircularView()<br>    }<br>    <br>    // MARK: - Setup Circular View<br>    <br>    private func setupCircularView() {<br>        let percentages: [Double] = [25, 25, 25, 15, 10] // Example data percentages<br>        let colors: [UIColor] = [.red, .green, .blue, .orange, .systemYellow] // Example colors<br>        <br>        // Initialize Pie Chart view<br>        circularView = PieChartCircular(percentages: percentages, colors: colors)<br>        circularView.translatesAutoresizingMaskIntoConstraints = false<br>        <br>        // Add Pie Chart view to the main view<br>        view.addSubview(circularView)<br>        <br>        // Setup constraints for Pie Chart view<br>        NSLayoutConstraint.activate([<br>            circularView.centerXAnchor.constraint(equalTo: view.centerXAnchor),<br>            circularView.centerYAnchor.constraint(equalTo: view.centerYAnchor),<br>            circularView.widthAnchor.constraint(equalToConstant: 200),<br>            circularView.heightAnchor.constraint(equalToConstant: 200)<br>        ])<br>    }<br>}</pre><pre>import UIKit<br><br>open class PieChartCircular: UIView {<br>    <br>    // MARK: - Public Properties<br>    public var lineWidth: CGFloat {<br>        get {<br>            return _lineWidth<br>        }<br>        set(newValue) {<br>            _lineWidth = newValue<br>            setNeedsDisplay()<br>        }<br>    }<br>    <br>    // MARK: - Private Variables<br>    private var _percentages: [Double]<br>    private var _colors: [UIColor]<br>    private var _lineWidth = CGFloat(10.0)<br>    <br>    // MARK: - Initialization<br>    public init(percentages: [Double], colors: [UIColor], lineWidth: CGFloat = 10.0) {<br>        self._percentages = percentages<br>        self._colors = colors<br>        self._lineWidth = lineWidth<br>        super.init(frame: CGRect.zero)<br>        self.backgroundColor = .clear<br>        self.clipsToBounds = false<br>    }<br>    <br>    required public init?(coder: NSCoder) {<br>        fatalError(&quot;init(coder:) has not been implemented&quot;)<br>    }<br>    <br>    // MARK: - Drawing<br>    override public func draw(_ rect: CGRect) {<br>        var startAngle: CGFloat = -CGFloat.pi / 2<br>        <br>        for i in 0..&lt;_percentages.count {<br>            let endAngle = startAngle + CGFloat(_percentages[i] / 100.0) * 2 * CGFloat.pi<br>            let path = UIBezierPath()<br>            path.move(to: CGPoint(x: rect.midX, y: rect.midY))<br>            path.addArc(withCenter: CGPoint(x: rect.midX, y: rect.midY), radius: rect.width / 2, startAngle: startAngle, endAngle: endAngle, clockwise: true)<br>            path.close()<br>            <br>            let shapeLayer = CAShapeLayer()<br>            shapeLayer.fillColor = _colors[i].cgColor<br>            shapeLayer.path = path.cgPath<br>            layer.addSublayer(shapeLayer)<br>            <br>            startAngle = endAngle<br>        }<br>    }<br>}</pre><h3>Doughnut Chart (with Hollow Center)</h3><p>A Doughnut Chart is similar to a Pie Chart, but with a hollow center. This can be achieved by drawing two concentric circles and connecting them with arcs. Let’s implement it:</p><pre>import UIKit<br><br>class DoughnutChartViewController: UIViewController {<br>    <br>    // MARK: - Properties<br>    <br>    var circularView: DoughnutChartCircular!<br>    <br>    // MARK: - View Lifecycle<br>    <br>    override func viewDidLoad() {<br>        super.viewDidLoad()<br>        view.backgroundColor = .systemBackground<br>        <br>        setupCircularView()<br>    }<br>    <br>    // MARK: - Setup Circular View<br>    <br>    private func setupCircularView() {<br>        let percentages: [Double] = [25, 25, 25, 15, 10] // Example data percentages<br>        let colors: [UIColor] = [.red, .green, .blue, .orange, .systemYellow] // Example colors<br>        <br>        // Initialize Doughnut Chart view<br>        circularView = DoughnutChartCircular(percentages: percentages, colors: colors)<br>        circularView.translatesAutoresizingMaskIntoConstraints = false<br>        <br>        // Add Doughnut Chart view to the main view<br>        view.addSubview(circularView)<br>        <br>        // Setup constraints for Doughnut Chart view<br>        NSLayoutConstraint.activate([<br>            circularView.centerXAnchor.constraint(equalTo: view.centerXAnchor),<br>            circularView.centerYAnchor.constraint(equalTo: view.centerYAnchor),<br>            circularView.widthAnchor.constraint(equalToConstant: 200),<br>            circularView.heightAnchor.constraint(equalToConstant: 200)<br>        ])<br>    }<br>}</pre><pre>import UIKit<br><br>open class DoughnutChartCircular: UIView {<br>    <br>    // MARK: - Public Properties<br>    public var lineWidth: CGFloat {<br>        get {<br>            return _lineWidth<br>        }<br>        set(newValue) {<br>            _lineWidth = newValue<br>            setNeedsDisplay()<br>        }<br>    }<br>    <br>    // MARK: - Private Variables<br>    private var _percentages: [Double]<br>    private var _colors: [UIColor]<br>    private var _lineWidth = CGFloat(10.0)<br>    <br>    // MARK: - Initialization<br>    public init(percentages: [Double], colors: [UIColor], lineWidth: CGFloat = 10.0) {<br>        self._percentages = percentages<br>        self._colors = colors<br>        self._lineWidth = lineWidth<br>        super.init(frame: CGRect.zero)<br>        self.backgroundColor = .clear<br>        self.clipsToBounds = false<br>    }<br>    <br>    required public init?(coder: NSCoder) {<br>        fatalError(&quot;init(coder:) has not been implemented&quot;)<br>    }<br>    <br>    // MARK: - Drawing<br>    override public func draw(_ rect: CGRect) {<br>        let center = CGPoint(x: rect.midX, y: rect.midY)<br>        let outerRadius = min(rect.width, rect.height) / 2 - _lineWidth / 2<br>        let innerRadius = outerRadius * 0.5 // Adjust the multiplier as needed for the size of the hole<br>        <br>        var startAngle: CGFloat = -CGFloat.pi / 2<br>        <br>        for i in 0..&lt;_percentages.count {<br>            let endAngle = startAngle + CGFloat(_percentages[i] / 100.0) * 2 * CGFloat.pi<br>            <br>            let path = UIBezierPath()<br>            path.move(to: CGPoint(x: center.x + outerRadius * cos(startAngle), y: center.y + outerRadius * sin(startAngle)))<br>            path.addArc(withCenter: center, radius: outerRadius, startAngle: startAngle, endAngle: endAngle, clockwise: true)<br>            path.addLine(to: CGPoint(x: center.x + innerRadius * cos(endAngle), y: center.y + innerRadius * sin(endAngle)))<br>            path.addArc(withCenter: center, radius: innerRadius, startAngle: endAngle, endAngle: startAngle, clockwise: false)<br>            path.close()<br>            <br>            let shapeLayer = CAShapeLayer()<br>            shapeLayer.fillColor = _colors[i].cgColor<br>            shapeLayer.path = path.cgPath<br>            layer.addSublayer(shapeLayer)<br>            <br>            startAngle = endAngle<br>        }<br>    }<br>}</pre><h3>Circular Chart with Arcs (with Overlapping Ends)</h3><p>Lastly, let’s create a Circular Chart with arcs. This type of chart represents data as arcs around a circle. We’ll implement it with overlapping ends for aesthetic appeal.</p><pre>import UIKit<br><br>class ArcsChartViewController: UIViewController {<br>    <br>    // MARK: - Properties<br>    <br>    var circularView: Circular!<br>    <br>    // MARK: - View Lifecycle<br>    <br>    override func viewDidLoad() {<br>        super.viewDidLoad()<br>        view.backgroundColor = .systemBackground<br>        <br>        setupCircularView()<br>    }<br>    <br>    // MARK: - Setup Circular View<br>    <br>    private func setupCircularView() {<br>        let percentages: [Double] = [25, 25, 25, 15, 10] // Example data percentages<br>        let colors: [UIColor] = [.red, .green, .blue, .orange, .systemYellow] // Example colors<br>        <br>        // Initialize Circular Chart view<br>        circularView = Circular(percentages: percentages, colors: colors)<br>        circularView.translatesAutoresizingMaskIntoConstraints = false<br>        <br>        // Add Circular Chart view to the main view<br>        view.addSubview(circularView)<br>        <br>        // Setup constraints for Circular Chart view<br>        NSLayoutConstraint.activate([<br>            circularView.centerXAnchor.constraint(equalTo: view.centerXAnchor),<br>            circularView.centerYAnchor.constraint(equalTo: view.centerYAnchor),<br>            circularView.widthAnchor.constraint(equalToConstant: 200),<br>            circularView.heightAnchor.constraint(equalToConstant: 200)<br>        ])<br>    }<br>}</pre><pre>import UIKit<br><br>open class Circular: UIView {<br>    <br>    // MARK: - Public Properties<br>    public var animationType: AnimationStyle {<br>        get {<br>            return _animationType<br>        }<br>        set(newValue) {<br>            _animationType = newValue<br>            setNeedsDisplay()<br>        }<br>    }<br>    <br>    public var showPercentageStyle: PercentageStyle {<br>        get {<br>            return _showPercentageStyle<br>        }<br>        set(newValue) {<br>            _showPercentageStyle = newValue<br>            setNeedsDisplay()<br>        }<br>    }<br>    <br>    public var lineWidth: CGFloat {<br>        get {<br>            return _lineWidth<br>        }<br>        set(newValue) {<br>            _lineWidth = newValue<br>            setNeedsDisplay()<br>        }<br>    }<br>    <br>    //  MARK:- Private Variable<br>    <br>    private var _percentages: [Double]<br>    private var _colors: [UIColor]<br>    private var _lineWidth = CGFloat(10.0)<br>    private var _animationType: AnimationStyle<br>    private var _showPercentageStyle: PercentageStyle<br>    <br>    //MARK:- Initialization<br>    public init(percentages: [Double], colors: [UIColor], animationType: AnimationStyle = .animationFanAll, showPercentageStyle: PercentageStyle = .none) {<br>        self._percentages = percentages<br>        self._colors = colors<br>        self._animationType = animationType<br>        self._showPercentageStyle = showPercentageStyle<br>        super.init(frame: CGRect.zero)<br>        self.backgroundColor = .clear<br>        self.clipsToBounds = false<br>    }<br>    <br>    required public init?(coder: NSCoder) {<br>        fatalError(&quot;init(coder:) has not been implemented&quot;)<br>    }<br>    <br>    //MARK:- draw<br>    override public func draw(_ rect: CGRect) {<br>        var startAngle = -90.0<br>        <br>        for i in 0..&lt;_percentages.count {<br>            let endAngle = startAngle + (_percentages[i] * 3.6) + 1<br>            let shapeLayer = self.addArc(with: _colors[i], in: rect, startAngle: startAngle, endAngle: endAngle)<br>            showAnimationStyle(index: Double(i), shapeLayer: shapeLayer, startAngle: startAngle, endAngle: endAngle)<br>            showPercentages(midAngel: startAngle + (endAngle - startAngle)/2, percentage: _percentages[i])<br>            startAngle = (endAngle - 1)<br>        }<br>    }<br>    <br>    //MARK:- Animations Functions<br>    private func showAnimationStyle(index: Double, shapeLayer: CAShapeLayer, startAngle: Double, endAngle: Double) {<br>        switch _animationType {<br>        case .animationFanAll:<br>            maskEachLayerAnimation(startAngal: startAngle, endAngal: endAngle + 4, shape: shapeLayer)<br>        case .animationFan:<br>            if Int(index) == _percentages.count - 1 {<br>                maskAnimation()<br>            }<br>        case .animationFadeIn:<br>            oppacityAnimation(index: index, shape: shapeLayer)<br>        case .animationthreeD:<br>            transformAnimation(index: index, shape: shapeLayer)<br>        case .none:<br>            break<br>        }<br>    }<br>    <br>    private  func oppacityAnimation(index: Double, shape: CAShapeLayer) {<br>        shape.opacity = 0<br>        DispatchQueue.main.asyncAfter(deadline: .now() + Double(index)/2.5 ) {<br>            shape.opacity = 1<br>            let animation = CABasicAnimation(keyPath: &quot;opacity&quot;)<br>            animation.fromValue = 0<br>            animation.toValue = 1<br>            animation.duration = 1<br>            shape.add(animation, forKey: nil)<br>        }<br>    }<br>    <br>    private func transformAnimation(index: Double, shape: CAShapeLayer) {<br>        shape.opacity = 0<br>        DispatchQueue.main.asyncAfter(deadline: .now() + Double(index)/2.5 ) {<br>            shape.opacity = 1<br>            let animation = CABasicAnimation(keyPath: &quot;transform&quot;)<br>            animation.fromValue = CATransform3DMakeScale(0, 0, 1)<br>            animation.toValue = CATransform3DIdentity<br>            animation.duration = 1<br>            shape.add(animation, forKey: nil)<br>        }<br>    }<br>    <br>    private func maskEachLayerAnimation(startAngal: Double, endAngal: Double, shape: CAShapeLayer) {<br>        let shapeLayer = CAShapeLayer()<br>        shapeLayer.fillColor = UIColor.clear.cgColor<br>        shapeLayer.strokeColor = UIColor.green.cgColor<br>        shapeLayer.lineWidth = max(bounds.maxX, bounds.maxY) / 5<br>        shapeLayer.frame = bounds<br>        let center = CGPoint(x: bounds.midX, y: bounds.midY)<br>        let longestSide = max(bounds.height, bounds.width)<br>        shapeLayer.path = UIBezierPath(arcCenter: center, radius: longestSide/2, startAngle: CGFloat(startAngal).deg2rad(), endAngle: CGFloat(endAngal).deg2rad(), clockwise: true).cgPath<br>        shapeLayer.strokeEnd = 0<br>        shape.mask = shapeLayer<br>        <br>        addAnimationToLayer(toLayer: shape, fromLayer: shapeLayer)<br>    }<br>    <br>    private func maskAnimation() {<br>        let shapeLayer = CAShapeLayer()<br>        shapeLayer.fillColor = UIColor.clear.cgColor<br>        shapeLayer.strokeColor = UIColor.white.cgColor<br>        shapeLayer.lineWidth = max(bounds.maxX, bounds.maxY) / 2<br>        shapeLayer.frame = bounds<br>        let path = UIBezierPath(arcCenter: CGPoint(x:bounds.midX,y:bounds.midY), radius:max( bounds.maxX/2,bounds.maxY/2), startAngle: CGFloat(-89.0).deg2rad(), endAngle: CGFloat(270.0).deg2rad(), clockwise: true)<br>        <br>        shapeLayer.path = path.cgPath<br>        shapeLayer.strokeEnd = 0<br>        self.layer.mask = shapeLayer<br>        <br>        addAnimationToLayer(toLayer: self.layer, fromLayer: shapeLayer)<br>    }<br>    <br>    private func addAnimationToLayer(toLayer: CALayer, fromLayer: CAShapeLayer) {<br>        CATransaction.begin()<br>        CATransaction.setCompletionBlock {<br>            toLayer.mask = nil<br>        }<br>        <br>        let animation = CABasicAnimation(keyPath: &quot;strokeEnd&quot;)<br>        animation.beginTime = CACurrentMediaTime() + 0.3<br>        animation.fromValue = 0<br>        animation.toValue = 1<br>        animation.fillMode = .forwards<br>        animation.isRemovedOnCompletion = false<br>        animation.duration = 1<br>        fromLayer.add(animation, forKey: &quot;line&quot;)<br>        <br>        CATransaction.commit()<br>    }<br>    <br>    //MARK:- show percentages<br>    private func showPercentages(midAngel: Double, percentage: Double) {<br>        guard let radius = getRadiusOfPercentage() else {<br>            return<br>        }<br>        <br>        let center = CGPoint(x: bounds.maxX / 2, y: bounds.maxY / 2)<br>        <br>        let  x = center.x  + (radius) * CGFloat(cos(CGFloat(midAngel).deg2rad()))<br>        let  y = center.y  + (radius) * CGFloat(sin(CGFloat(midAngel).deg2rad()))<br>        <br>        let percentageLabel  = UILabel(frame: CGRect.zero)<br>        percentageLabel.frame = CGRect.zero<br>        percentageLabel.text = String(percentage)<br>        percentageLabel.textColor = .black<br>        percentageLabel.font = UIFont.boldSystemFont(ofSize: 12)<br>        percentageLabel.sizeToFit()<br>        percentageLabel.center = CGPoint(x: x, y: y)<br>        addSubview(percentageLabel)<br>        percentageLabel.alpha = 0<br>        <br>        var delay = 1.5<br>        if self.animationType == .none {<br>            delay = 0<br>        }<br>        <br>        UIView.animate(withDuration: 0.5, delay: delay, options: .curveEaseOut, animations: {<br>            percentageLabel.alpha = 1<br>        })<br>    }<br>    <br>    private func getRadiusOfPercentage() -&gt; CGFloat? {<br>        let longestSide = max(bounds.height, bounds.width)<br>        switch self.showPercentageStyle {<br>        case .inward:<br>            return longestSide/3 - lineWidth<br>        case .over:<br>            return longestSide/2 - lineWidth<br>        case .outward:<br>            return longestSide/2  + lineWidth + 5<br>        case .none:<br>            return nil<br>        }<br>    }<br>    <br>    //MARK:- Drawing Code<br>    private func addArc(with color: UIColor, in rect: CGRect, startAngle: Double, endAngle: Double) -&gt; CAShapeLayer {<br>        let center = CGPoint(x: rect.maxX / 2, y: rect.maxY / 2)<br>        let longestSide = max(rect.height, rect.width)<br>        let lineWidth = CGFloat(self._lineWidth / 20)<br>        let smallCircleRadious = (longestSide / (2 + lineWidth))<br>        let startAngle = CGFloat(startAngle)<br>        let endAngle = CGFloat(endAngle)<br>        let outerRadious =  (longestSide / 2)<br>        let midPoint = (longestSide / (2 + lineWidth/2.7))<br>        let path = UIBezierPath()<br>        let  x3 = center.x  + (outerRadious) * CGFloat(cos(startAngle.deg2rad()))<br>        let  y3 = center.y  + (outerRadious) * CGFloat(sin(startAngle.deg2rad()))<br>        let  x4 = center.x  + (smallCircleRadious) * CGFloat(cos(startAngle.deg2rad()))<br>        let  y4 = center.y  + (smallCircleRadious) * CGFloat(sin(startAngle.deg2rad()))<br>        let  x5 = center.x  + (midPoint) * CGFloat(cos((startAngle + self._lineWidth * 0.5).deg2rad()))<br>        let  y5 = center.y  + (midPoint) * CGFloat(sin((startAngle +  self._lineWidth * 0.5).deg2rad()))<br>        path.move(to: CGPoint(x: x4, y: y4))<br>        path.addQuadCurve(to: CGPoint(x: x3, y: y3), controlPoint: CGPoint(x: x5, y: y5))<br>        path.addArc(withCenter: center, radius: outerRadious, startAngle: startAngle.deg2rad(), endAngle: endAngle.deg2rad(), clockwise: true)<br>        let  x1 = center.x  + (outerRadious) * CGFloat(cos(endAngle.deg2rad()))<br>        let  y1 = center.y  + (outerRadious) * CGFloat(sin(endAngle.deg2rad()))<br>        let  x6 = center.x  + (midPoint) * CGFloat(cos((endAngle + self._lineWidth * 0.6).deg2rad()))<br>        let  y6 = center.y  + (midPoint) * CGFloat(sin((endAngle + self._lineWidth * 0.6).deg2rad()))<br>        let  x2 = center.x  + (smallCircleRadious) * CGFloat(cos(endAngle.deg2rad()))<br>        let  y2 = center.y  + (smallCircleRadious) * CGFloat(sin(endAngle.deg2rad()))<br>        path.move(to: CGPoint(x: x1, y: y1))<br>        path.addQuadCurve(to: CGPoint(x: x2, y: y2), controlPoint: CGPoint(x: x6, y: y6))<br>        path.addArc(withCenter: center, radius: smallCircleRadious, startAngle:  endAngle.deg2rad(), endAngle: startAngle.deg2rad(), clockwise: false)<br>        let shape = CAShapeLayer()<br>        shape.frame = bounds<br>        shape.lineCap = .round<br>        shape.fillColor = color.cgColor<br>        shape.path = path.cgPath<br>        layer.addSublayer(shape)<br>        return shape<br>    }<br>}<br><br>extension CGFloat {<br>    func deg2rad() -&gt; CGFloat {<br>        return self * .pi / 180<br>    }<br>}</pre><p>In this article, we’ve covered how to create three types of custom charts: Pie Chart, Doughnut Chart, and Circular Chart with arcs. Each chart type has its own unique characteristics and implementation details. By following the provided Swift code snippets and explanations, you should now have a solid understanding of how to create these custom charts in your iOS apps. Happy coding!</p><p>References:</p><ul><li><a href="https://stackoverflow.com/questions/60274980/uibezierpath-custom-linecapstyle-different-on-both-ends">UIBezierPath Custom lineCapStyle different on both Ends</a></li><li><a href="https://stackoverflow.com/questions/74532717/chart-with-uibezierpath-at-one-below-one">Chart with UIBezierPath at one below one</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=959551e1f7eb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Beginner’s Guide to Contributing to Open-Source iOS Projects on GitHub]]></title>
            <link>https://medium.com/@ipak.tulane/a-beginners-guide-to-contributing-to-open-source-ios-projects-on-github-bf0068a4d78c?source=rss-62d93c89df20------2</link>
            <guid isPermaLink="false">https://medium.com/p/bf0068a4d78c</guid>
            <category><![CDATA[gsoc]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[github]]></category>
            <category><![CDATA[open-source]]></category>
            <dc:creator><![CDATA[Igor Pak]]></dc:creator>
            <pubDate>Thu, 04 Apr 2024 06:59:47 GMT</pubDate>
            <atom:updated>2024-04-04T06:59:47.706Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Swift is not only the primary language for iOS development but also the most popular open-source language on GitHub. Contributing to open-source Swift projects on GitHub offers iOS developers a valuable opportunity to collaborate globally and enhance their skills.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W5MBAD3Yq-hFGIJG30R03g.jpeg" /></figure><p>GitHub offers a plethora of opportunities to collaborate with developers worldwide on exciting projects. In this guide, we’ll walk you through the step-by-step process of making your first contribution to an open-source iOS project on GitHub.</p><h3>1. Choose a Project</h3><p>The first step is to find a project that aligns with your interests and skills. Look for projects with active maintainers, clear documentation, and a welcoming community. Explore GitHub’s trending repositories or search for specific keywords related to iOS development.</p><p>Here is the link to the curated list of projects: <a href="https://medium.mybridge.co/21-amazing-open-source-ios-apps-written-in-swift-5e835afee98e">Curated List of Open-Source iOS Projects</a>. As a starting point, consider exploring official GitHub open-source projects written in Swift. These projects, such as <a href="https://github.com/mozilla-mobile/firefox-ios">Firefox for iOS</a>, <a href="https://github.com/wordpress-mobile/WordPress-iOS">WordPress for iOS</a>, <a href="https://github.com/artsy/eidolon">Eidolon by Artsy</a>, and <a href="https://github.com/lexrus/VPNOn">VPNOn by Lexrus</a>, provide valuable opportunities to learn best practices and contribute to established projects.</p><h3>2. Fork the Repository</h3><p>Once you’ve found a project you’d like to contribute to, fork the repository to create your copy under your GitHub account. This allows you to freely experiment with changes without affecting the original project.</p><h3>3. Clone Your Fork</h3><p>Clone the forked repository to your local machine using the git clone command. This creates a local copy of the project on your computer where you can make changes and contribute.</p><h3>4. Create a Branch</h3><p>Create a new branch for your contribution using the git checkout -b command. Branch names should be descriptive, indicating the feature or bug you&#39;re addressing. This helps maintain clarity and organization within the project.</p><h3>5. Make Changes</h3><p>Now comes the fun part — making your desired changes to the codebase! Follow the project’s coding style and conventions, and don’t forget to add new tests or update existing ones to maintain code quality.</p><h3>6. Commit Your Changes</h3><p>Stage your changes for commit using git add and then commit them with a clear and concise message using git commit -m. A well-written commit message helps maintainers understand the purpose of your contribution.</p><h3>7. Sync with Upstream</h3><p>Before pushing your changes, sync your fork with the original repository to incorporate any changes made by others. This ensures that your contribution is based on the latest version of the project.</p><h3>8. Push Changes</h3><p>Push your changes to your forked repository on GitHub using git push origin &lt;branch-name&gt;. This makes your changes visible to others and allows you to create a pull request (PR) for review.</p><h3>9. Create a Pull Request (PR)</h3><p>Navigate to your forked repository on GitHub and click on the “New pull request” button. Compare the changes between your branch and the original repository’s main branch, then create the pull request.</p><h3>10. Describe Your Changes</h3><p>Provide a clear and detailed description of the changes you’ve made in the pull request. This helps the maintainers understand the purpose of your contribution and facilitates the review process.</p><h3>11. Respond to Feedback</h3><p>Be open to feedback from maintainers and other contributors. Address any requested changes promptly and courteously, and engage in constructive discussions to improve your contribution.</p><h3>12. Maintain Your Branch</h3><p>Keep your feature branch up to date with the main branch by regularly pulling changes from the upstream repository. This ensures that your contribution remains compatible with the latest version of the project.</p><h3>13. <strong>Google Summer of Code</strong></h3><p>Contributing to open-source projects on GitHub offers aspiring iOS developers a chance to sharpen their skills and leave a lasting impact. Google Summer of Code (GSoC), now celebrating its 20th year, provides students with invaluable real-world experience, collaboration opportunities, and generous stipends.</p><p>With projects spanning Artificial Intelligence, Machine Learning, and Security, GSoC opens doors for diverse contributions. Engage with the application process by exploring mentoring organizations, selecting projects, and reaching out before the deadline. Join the vibrant open-source community and enhance your development prowess with GSoC. Watch an intro to GSoC <a href="https://www.youtube.com/watch?v=7jD2tChhrWM&amp;ab_channel=GoogleOpenSource">here</a>.</p><p>Contributing to open-source projects is a rewarding journey that allows you to learn, collaborate, and make a meaningful impact on the developer community. So what are you waiting for? Dive in and start making your mark on GitHub today!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bf0068a4d78c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Live Preview in iOS Development: A Comprehensive Guide]]></title>
            <link>https://medium.com/@ipak.tulane/live-preview-in-ios-development-a-comprehensive-guide-2fd87604a8c4?source=rss-62d93c89df20------2</link>
            <guid isPermaLink="false">https://medium.com/p/2fd87604a8c4</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[tools]]></category>
            <category><![CDATA[swiftui]]></category>
            <category><![CDATA[live-previews]]></category>
            <dc:creator><![CDATA[Igor Pak]]></dc:creator>
            <pubDate>Fri, 09 Feb 2024 17:39:54 GMT</pubDate>
            <atom:updated>2024-02-09T17:39:54.104Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>Live Preview is a powerful feature in iOS development that allows developers to see real-time changes in their UI as they code, providing an interactive and efficient development experience. In this article, we’ll explore how to leverage Live Preview using Swift and SwiftUI to enhance the development workflow.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dgrSdDiri1vNgiJunNQANw.jpeg" /></figure><h3>The Basics: Setting Up Live Preview</h3><p>Live Preview is particularly beneficial for developers who prefer a programmatic approach to UI development. Let’s start with a simple example using a UIViewController and SwiftUI’s PreviewProvider.</p><h3>Step 1: Initial Setup</h3><p>The provided Swift code introduces a basic UIViewController with a red background and a label displaying &quot;Hello, World!&quot; To enable Live Preview, we&#39;ll use SwiftUI&#39;s PreviewProvider protocol.</p><pre>#if DEBUG<br>@available(iOS 13.0, *)<br>struct VCProvider: PreviewProvider {<br>    static var previews: some View {<br>        ViewController().showPreview()<br>    }<br>}<br>#endif</pre><p>This code snippet defines a PreviewProvider for the ViewController, making it available for Live Preview in Xcode.</p><h3>Step 2: SwiftUI Extension</h3><p>To bridge between UIKit and SwiftUI, we create a SwiftUI UIViewControllerRepresentable extension. This enables us to embed the UIViewController in a SwiftUI view hierarchy.</p><pre>import SwiftUI<br><br>@available(iOS 13.0, *)<br>extension UIViewController {<br><br>    private struct Preview: UIViewControllerRepresentable {<br>        <br>        let vc: UIViewController<br>        <br>        func makeUIViewController(context: Context) -&gt; some UIViewController {<br>            vc<br>        }<br>        <br>        func updateUIViewController(_ uiViewController: UIViewControllerType, context: Context) {<br>            // Additional configuration if needed<br>        }<br>        <br>    }<br>    <br>    func showPreview() -&gt; some View {<br>        Preview(vc: self).edgesIgnoringSafeArea(.all)<br>    }<br>    <br>}</pre><p>This extension defines a Preview structure conforming to UIViewControllerRepresentable, allowing the UIViewController to be embedded in SwiftUI.</p><h3>Step 3: Live Preview</h3><p>With these components in place, you can now see Live Preview in action. Open Xcode, navigate to the ContentView.swift file, and select the Live Preview button in the canvas.</p><h3>Advanced Concepts: Enhancing Live Preview</h3><p>Now that we have the basics covered, let’s explore advanced concepts to further enhance the Live Preview experience.</p><h3>1. Dynamic Data Binding</h3><p>One of the advantages of Live Preview is the ability to visualize dynamic data changes. Let’s modify our ViewController to include a dynamic greeting message.</p><pre>class ViewController: UIViewController {    <br>// ... Existing code<br><br>var greeting: String = &quot;Hello, World!&quot; {<br>        didSet {<br>            helloLabel.text = greeting<br>        }<br>    }<br>    override func viewDidLoad() {<br>        super.viewDidLoad()<br>        view.backgroundColor = .red<br>        setupConstraints()<br>        greeting = &quot;Welcome to Live Preview!&quot;<br>    }<br>    // ... Remaining code<br>}</pre><p>By introducing a dynamic greeting variable, we can observe real-time updates in the Live Preview as the content of the label changes dynamically.</p><h3>2. Dark Mode Preview</h3><p>Live Preview allows developers to preview their UI in different interface styles. Let’s enhance the Live Preview to support dark mode.</p><pre>@available(iOS 13.0, *)<br>struct VCProvider: PreviewProvider {<br>    static var previews: some View {<br>        Group {<br>            ViewController().showPreview()<br>                .environment(\.colorScheme, .light)<br>            ViewController().showPreview()<br>                .environment(\.colorScheme, .dark)<br>        }<br>    }<br>}</pre><p>By embedding the ViewController in a Group with different color schemes, we can preview the UI in both light and dark modes simultaneously.</p><h3>3. Interactivity in Preview</h3><p>To simulate user interactions and test different states, we can add interactive elements to our Live Preview.</p><pre>@available(iOS 13.0, *)<br>struct VCProvider: PreviewProvider {<br>    static var previews: some View {<br>        ViewController().showPreview()<br>            .previewLayout(.sizeThatFits)<br>            .previewDisplayName(&quot;Interactive Preview&quot;)<br>            .onTapGesture {<br>                // Handle tap gesture<br>                print(&quot;Tapped on Live Preview!&quot;)<br>            }<br>    }<br>}</pre><p>In this example, we’ve added an onTapGesture modifier to the Live Preview, allowing us to simulate a tap gesture and observe the UI&#39;s response.</p><h3>Conclusion</h3><p>Live Preview is a valuable tool for iOS developers, offering a real-time preview of their UI as they write code. By combining SwiftUI and UIKit in a programmatic approach, developers can create a seamless Live Preview experience. From basic setup to advanced concepts, mastering Live Preview enhances the development workflow, making it an indispensable tool for every iOS developer.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2fd87604a8c4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Conditional Compilation in Swift with #if DEBUG]]></title>
            <link>https://medium.com/@ipak.tulane/conditional-compilation-in-swift-with-if-debug-056a460ca686?source=rss-62d93c89df20------2</link>
            <guid isPermaLink="false">https://medium.com/p/056a460ca686</guid>
            <category><![CDATA[debug]]></category>
            <category><![CDATA[compilation]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[directives]]></category>
            <dc:creator><![CDATA[Igor Pak]]></dc:creator>
            <pubDate>Fri, 02 Feb 2024 13:58:28 GMT</pubDate>
            <atom:updated>2024-02-02T13:58:28.247Z</atom:updated>
            <content:encoded><![CDATA[<p>Conditional compilation directives in Swift, such as #if DEBUG and #endif, are powerful tools that allow developers to include or exclude code based on the build configuration. This feature is particularly handy for incorporating debugging aids, logging statements, or development-specific functionality that should be present only during the development phase and excluded in the final release version of the application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*TcDKwxMMRFRwJ3iHtEQZcw.png" /></figure><h3>Understanding #if DEBUG</h3><p>The #if DEBUG directive checks if the build configuration is set to DEBUG. If it is, the enclosed code is included during compilation; otherwise, it&#39;s excluded.</p><h3>Practical Example</h3><p>Let’s consider a scenario where you want to print debugging information during development but exclude it from the release build:</p><pre>#if DEBUG<br> print(“Debugging information: \(someDebugInfo)”)<br>#else<br> // No debugging information in release build<br>#endif</pre><p>In this example, the print(&quot;Debugging information: \(someDebugInfo)&quot;) line will be present in the code only when building the application with the DEBUG configuration. When switched to the release configuration, the debugging information is excluded, keeping the release version clean and optimized.</p><h3>Best Practices</h3><p>When using conditional compilation, it’s crucial to follow best practices:</p><ol><li><strong>Avoid Excessive Debug Code: </strong>Include only essential debugging aids to prevent unnecessary overhead in release builds.</li><li><strong>Clear Documentation:</strong> Add comments to explain the purpose of the conditional code, making it easier for other developers to understand.</li><li><strong>Consistent Configuration: </strong>Ensure that the DEBUG configuration is set appropriately in your Xcode project settings.</li></ol><h3>Conclusion</h3><p>Conditional compilation with #if DEBUG is a valuable feature in Swift, enabling developers to enhance the development experience without affecting the release version of the application. By judiciously using these directives, you can streamline your codebase and create a more maintainable and optimized final product.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=056a460ca686" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>