<?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 Udaykumar on Medium]]></title>
        <description><![CDATA[Stories by Udaykumar on Medium]]></description>
        <link>https://medium.com/@UdayiOS_dev?source=rss-f85eb8033ae5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*MeZjANyWpPMfrdhNf2gTzQ.jpeg</url>
            <title>Stories by Udaykumar on Medium</title>
            <link>https://medium.com/@UdayiOS_dev?source=rss-f85eb8033ae5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 20:33:59 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@UdayiOS_dev/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How to Set Up Universal Links in iOS]]></title>
            <link>https://medium.com/@UdayiOS_dev/how-to-set-up-universal-links-in-ios-fbea9da00a50?source=rss-f85eb8033ae5------2</link>
            <guid isPermaLink="false">https://medium.com/p/fbea9da00a50</guid>
            <dc:creator><![CDATA[Udaykumar]]></dc:creator>
            <pubDate>Thu, 13 Mar 2025 05:02:57 GMT</pubDate>
            <atom:updated>2025-03-13T05:02:57.128Z</atom:updated>
            <content:encoded><![CDATA[<h3>What are Apple iOS Universal Links?</h3><p>Apple introduced Universal Links in iOS 9 to address the limitations of custom URI schemes in deep linking. Universal Links are standard web links (e.g., http://mydomain.com) that can open content inside an app if it is installed or fallback to a webpage otherwise. If a registered app is found for a Universal Link, iOS launches it directly without loading the webpage.</p><h3>Universal Link Integration Guide</h3><p>To enable Universal Links in your iOS app, follow these steps:</p><h3>1. Register Your App at Apple Developer Portal</h3><ul><li>Log into <a href="https://developer.apple.com/">Apple Developer</a></li><li>Enable <strong>Associated Domains</strong> for your app identifier</li></ul><h3>2. Enable Associated Domains in Xcode</h3><ul><li>Open your project in Xcode</li><li>Navigate to <strong>Signing &amp; Capabilities</strong></li><li>Add an <strong>Associated Domains</strong> entry</li><li>Format the domain as: applinks:yourwebsite.com</li></ul><h3>3. Configure Your Website</h3><p>Your website must host an apple-app-site-association (AASA) file, which links your domain to your app.</p><h3>What is an AASA (apple-app-site-association) File?</h3><p>The AASA file is a JSON document that proves domain ownership and specifies URL paths for Universal Links. Unlike URI schemes (which lacked verification), Universal Links are secure because other apps cannot host an AASA file on a domain they don’t own.</p><h3>Example AASA File</h3><pre>{<br>  &quot;applinks&quot;: {<br>    &quot;apps&quot;: [],<br>    &quot;details&quot;: [<br>      {<br>        &quot;appID&quot;: &quot;KFFNVC27GU.com.yourcompany.YourProject&quot;, //(TeamID+Budle Id)<br>        &quot;paths&quot;: [&quot;*&quot;]<br>      }<br>    ]<br>  }<br>}</pre><h3>Components:</h3><ul><li><strong>Team ID</strong>: Found in your <a href="https://developer.apple.com/">Apple Developer</a> account under Membership.</li><li><strong>Bundle ID</strong>: Found in Xcode under <strong>General &gt; Bundle Identifier</strong>.</li></ul><h3>Hosting the AASA File</h3><ul><li>Place the file at: <a href="https://yourwebsite.com/apple-app-site-association">https://yourwebsite.com/apple-app-site-association</a></li><li>Serve it over <strong>HTTPS</strong></li><li>Use <strong>Content-Type: application/json</strong></li><li><strong>Do not</strong> append .json to the filename</li><li>File size must not exceed <strong>128 KB</strong></li></ul><h3>Validate AASA File</h3><p>Use <a href="https://branch.io/resources/aasa-validator/#resultsbox">Branch.io AASA Validator</a> or <a href="https://apnspush.com/aasa-validator/">https://apnspush.com/aasa-validator/</a> to ensure the file is correctly hosted.</p><h3>Handling Universal Links in Your App</h3><p>Once the setup is complete, handle Universal Links in AppDelegate.swift.</p><h3>Implement Universal Link Handling</h3><pre>//️Handling Universal Links in AppDelegate.swift<br><br>func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -&gt; Void) -&gt; Bool {<br>    guard userActivity.activityType == NSUserActivityTypeBrowsingWeb,<br>          let url = userActivity.webpageURL,<br>          let components = URLComponents(url: url, resolvingAgainstBaseURL: true) else {<br>        return false<br>    }<br>    <br>    debugPrint(&quot;URL==\(userActivity.webpageURL?.absoluteString ?? &quot;&quot;)&quot;)<br>    return true<br> }<br><br>//Using .onOpenURL Modifier (SwiftUI)<br><br> .onOpenURL { url in<br>    print(&quot;Opened URL: \(url)&quot;)<br> }<br><br>// Using .onContinueUserActivity Modifier (SwiftUI)<br><br> .onContinueUserActivity(NSUserActivityTypeBrowsingWeb) { userActivity in<br>    if let url = userActivity.webpageURL {<br>        print(&quot;Universal Link Opened: \(url)&quot;)<br>    } else {<br>        print(&quot;Invalid Universal Link&quot;)<br>    }<br>  }</pre><h3>Expected Output</h3><p>If successful, Universal Links will open the app directly when tapped, bypassing the browser.</p><h3>References</h3><p>For detailed information, visit <a href="https://developer.apple.com/library/archive/documentation/General/Conceptual/AppSearch/UniversalLinks.html">Apple’s Universal Links Documentation</a>.</p><p>That’s all, folks! Now your iOS app is ready to handle Universal Links seamlessly.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fbea9da00a50" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Implementing File Import in SwiftUI with Security Scoped Resources]]></title>
            <link>https://medium.com/@UdayiOS_dev/implementing-file-import-in-swiftui-with-security-scoped-resources-8c9a9a536ce9?source=rss-f85eb8033ae5------2</link>
            <guid isPermaLink="false">https://medium.com/p/8c9a9a536ce9</guid>
            <dc:creator><![CDATA[Udaykumar]]></dc:creator>
            <pubDate>Tue, 11 Mar 2025 04:54:18 GMT</pubDate>
            <atom:updated>2025-03-11T04:54:18.273Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>Handling file imports in SwiftUI can be crucial when working with user-uploaded documents, images, or PDFs. In this post, we will walk through implementing a file picker in SwiftUI using fileImporter and handling security-scoped resources efficiently.</p><h3>Setting Up File Import</h3><p>SwiftUI provides a built-in fileImporter modifier, allowing users to select files from their device. To process the imported file securely and retrieve its metadata (such as file size and type), we need to use startAccessingSecurityScopedResource() for external file access.</p><h3>Import Required Frameworks</h3><p>Before proceeding, make sure to import the necessary frameworks:</p><pre>import UniformTypeIdentifiers<br>import MobileCoreServices</pre><p>Below is a complete implementation of a file import handler:</p><h3>File Import Handler Function</h3><pre>private func handleFileImport(_ result: Result&lt;URL, Error&gt;) {<br>    switch result {<br>    case .success(let url):<br>        var fileSizeInMB: Double = 0.0<br><br>// Start accessing security-scoped resource<br>        if url.startAccessingSecurityScopedResource() {<br>            defer { url.stopAccessingSecurityScopedResource() } // Ensure it&#39;s stopped later<br>            do {<br>                let fileSize = try url.resourceValues(forKeys: [.fileSizeKey]).fileSize ?? 0<br>                fileSizeInMB = Double(fileSize) / (1024 * 1024) // Convert bytes to MB<br>                self.fileSize = String(format: &quot;%.2f MB&quot;, fileSizeInMB)<br>                let fileExtension = url.pathExtension.lowercased()<br>                if fileExtension == &quot;pdf&quot; {<br>                    selectedPDFURL = url<br>                    print(&quot;Selected PDF: \(url.lastPathComponent) | Size: \(self.fileSize!)&quot;)<br>                } else if [&quot;jpg&quot;, &quot;jpeg&quot;, &quot;png&quot;].contains(fileExtension) {<br>                    if let imageData = try? Data(contentsOf: url),<br>                       let _ = UIImage(data: imageData) {<br>                        selectedPDFURL = url<br>                        print(&quot;Selected Image: \(url.lastPathComponent) | Size: \(self.fileSize!)&quot;)<br>                    }<br>                } else if [&quot;doc&quot;, &quot;docx&quot;].contains(fileExtension) {<br>                    if let docType = UTType(filenameExtension: fileExtension),<br>                       docType.conforms(to: .item) {<br>                        selectedPDFURL = url<br>                        print(&quot;Selected Document: \(url.lastPathComponent) | Size: \(self.fileSize!)&quot;)<br>                    } else {<br>                        print(&quot;Unsupported Word file type: \(fileExtension)&quot;)<br>                    }<br>                } else {<br>                    print(&quot;Unsupported file type: \(fileExtension)&quot;)<br>                }<br>            } catch {<br>                print(&quot;Failed to get file size: \(error.localizedDescription)&quot;)<br>            }<br>        } else {<br>            print(&quot;Failed to access security-scoped resource for \(url.lastPathComponent)&quot;)<br>        }<br>    <br>    case .failure(let error):<br>        print(&quot;File import failed: \(error.localizedDescription)&quot;)<br>        exit(1) // Exit the app in case of failure<br>    }<br>}</pre><h3>File Import UI in SwiftUI</h3><p>Now, let’s integrate this function into a SwiftUI view where users can pick a file.</p><pre>if let pdfURL = selectedPDFURL {<br>    HStack(spacing: 5) {<br>        HStack {<br>            Image(systemName: &quot;doc.text&quot;)<br>                .resizable()<br>                .renderingMode(.template)<br>                .foregroundColor(.cyan)<br>                .frame(width: 20, height: 25)<br>        }<br>        .frame(width: 35, height: 35)<br>        <br>        VStack(alignment: .leading, spacing: 2) {<br>            Text(&quot;\(pdfURL.lastPathComponent)&quot;)<br>                .font(.regular14)<br>                .foregroundColor(.cyan)<br>                .frame(height: 15)<br>                .lineLimit(1)<br>                .truncationMode(.tail)<br>            Text(&quot;\(fileSize ?? &quot;&quot;)&quot;)<br>                .font(.regular14)<br>               .foregroundColor(.cyan)<br>        }<br>        Spacer()<br>    }<br>    .padding(.horizontal)<br>    .padding(.vertical, 10)<br>    .background(.glassmorphismCardColor2)<br>    .cornerRadius(8)<br>} else {<br>    Text(&quot;Choose from files (pdf, png, jpeg)&quot;)<br>       .foregroundColor(.cyan)<br>        .font(.semiBold14)<br>    Spacer()<br>    Image(systemName: &quot;doc.text&quot;)<br>        .foregroundColor(.cyan)<br>}<br>// Tap to show file picker<br>.padding()<br>.cornerRadius(8)<br>.onTapGesture {<br>    self.showFilePicker = true<br>}<br>//MARK:- USAGE OF FILE PICKER CODE<br>.fileImporter(<br>    isPresented: $showFilePicker,<br>    allowedContentTypes: [<br>        .image, .pdf, .data, .plainText, .rtf,<br>        .init(filenameExtension: &quot;doc&quot;)!,<br>        .init(filenameExtension: &quot;docx&quot;)!<br>    ]<br>) { result in<br>    handleFileImport(result)<br>}</pre><h3><strong>Explanation</strong></h3><ol><li><strong>Security-Scoped Access</strong>:</li></ol><ul><li>startAccessingSecurityScopedResource() is used to access files outside the app sandbox securely.</li><li>defer { url.stopAccessingSecurityScopedResource() } ensures that the resource is released once processing is complete.</li></ul><ol><li><strong>File Metadata Extraction</strong>:</li></ol><ul><li>url.resourceValues(forKeys: [.fileSizeKey]) retrieves the file size in bytes.</li><li>It is converted to MB for display.</li></ul><ol><li><strong>File Type Filtering</strong>:</li></ol><ul><li>Supported file types are PDFs, images (JPEG, PNG), and Word documents.</li><li>The UTType framework ensures the correct document type handling.</li></ul><ol><li><strong>UI Updates</strong>:</li></ol><ul><li>If a file is selected, its name and size are displayed.</li><li>Otherwise, a placeholder prompting the user to select a file is shown.</li></ul><ol><li><strong>Error Handling &amp; Exit Code</strong>:</li></ol><ul><li>If the file import fails, the application will exit with exit(1) to indicate an error.</li></ul><p><strong>Conclusion</strong></p><p>This implementation allows users to securely import files in SwiftUI while handling different file types and displaying essential metadata. Security-scoped resources ensure safe access, and fileImporter simplifies the file selection process.</p><p>Happy coding! 🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8c9a9a536ce9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Streamlining Navigation in SwiftUI: A Clean and Scalable Approach]]></title>
            <link>https://medium.com/@UdayiOS_dev/streamlining-navigation-in-swiftui-a-clean-and-scalable-approach-391cbe420ec3?source=rss-f85eb8033ae5------2</link>
            <guid isPermaLink="false">https://medium.com/p/391cbe420ec3</guid>
            <dc:creator><![CDATA[Udaykumar]]></dc:creator>
            <pubDate>Fri, 02 Aug 2024 14:42:57 GMT</pubDate>
            <atom:updated>2024-08-02T14:42:57.704Z</atom:updated>
            <content:encoded><![CDATA[<p>Navigating between screens in SwiftUI has traditionally been a bit cumbersome, especially as your app grows and requires more complex navigation flows. However, I’m excited to share a streamlined and efficient navigation system that leverages enums and generics to keep your code clean, maintainable, and scalable. This approach will enhance your SwiftUI projects and simplify the navigation management.</p><h3>The Concept: Enum-Driven Navigation</h3><p>This method revolves around using enums to define the various destinations within your app. By centralizing the navigation logic and view management, you can handle complex navigation scenarios with ease.</p><h4>1. NavigationEnum: Defining Destinations</h4><p>First, let’s define an enum that represents all possible navigation destinations in your app. This enum will act as a single source of truth for all the screens you want to navigate to.</p><pre>enum NavigationEnum: Hashable {<br>    case signUp<br>    case home<br>    case profile<br>}</pre><h4>2. Destination: Mapping Destinations to Views</h4><p>Next, we need a way to convert these enum values into their respective SwiftUI views. We accomplish this with a Destination class that provides a static method to map each enum case to its corresponding view.</p><pre>class Destination {<br>    static func setViewForDestination(_ destination: NavigationEnum) -&gt; AnyView {<br>        switch destination {<br>            case .signUp:<br>                return AnyView(SignUp())<br>            case .home:<br>                return AnyView(HomeView())<br>            case .profile:<br>                return AnyView(ProfileView())<br>        }<br>    }<br>}</pre><p>This setup allows you to keep all the view creation logic in one place, making it easy to manage and update as your app evolves.</p><h4>3. NavigationFlow: Managing the Navigation Path</h4><p>To handle the navigation logic, we use a NavigationFlow class that conforms to ObservableObject. This class manages the navigation stack and provides methods for navigating to different screens.Copy code</p><pre>class NavigationFlow: ObservableObject {<br>    static let shared = NavigationFlow()<br>    @Published var path = NavigationPath()<br>    <br>    func clear() {<br>        path = .init()<br>    }<br>    <br>    func navigateBackToRoot() {<br>        path.removeLast(path.count)<br>    }<br>    <br>    func backToPrevious() {<br>        path.removeLast()<br>    }<br>    <br>    func navigateToSignUp() {<br>        path.append(NavigationEnum.signUp)<br>    }<br>    <br>    func navigateToHome() {<br>        path.append(NavigationEnum.home)<br>    }<br>    <br>    func navigateToProfile() {<br>        path.append(NavigationEnum.profile)<br>    }<br>}</pre><p>This class provides convenient methods to navigate to different screens, clear the navigation stack, or go back to the previous screen.</p><h4>4. Usage Example: Integrating Navigation in SwiftUI</h4><p>Finally, let’s see how to integrate this navigation system into a SwiftUI view. We’ll use the NavigationFlow class to control the navigation and display different views based on the current navigation path.</p><pre>struct MyContentView: View {<br>    @EnvironmentObject var navFlow: NavigationFlow<br>    <br>    var body: some View {<br>        ZStack {<br>            NavigationStack(path: $navFlow.path) {<br>                VStack {<br>                    GetStartView()<br>                }<br>                .navigationDestination(for: NavigationEnum.self) { destination in<br>                    Destination.setViewForDestination(destination)<br>                        .navigationBarBackButtonHidden(true) // Optional: hide back button<br>                }<br>            }<br>        }<br>    }<br>}</pre><pre>NavigationFlow.shared.navigateToSignUp() // Here you can navigate by calling this method</pre><pre>struct GetStartView: View {<br>    var body: some View {<br>        ZStack {<br>            Color.cyan<br>                .ignoresSafeArea()<br>            VStack {<br>                Spacer()<br>                Text(&quot;Lorem ipsum dolor sit amet, consectetur adipiscing elit&quot;)<br>                    .foregroundStyle(Color.textNeutral0)<br>                    .font(.title)<br>                    .multilineTextAlignment(.center)<br>                Button(&quot;Start&quot;) {<br>                    NavigationFlow.shared.navigateToSignUp()<br>                }<br>            }<br>            .padding(.bottom)<br>            .safeAreaPadding(.bottom)<br>        }<br>        .ignoresSafeArea()<br>    }<br>}</pre><p>In this example, MyContentView sets up a NavigationStack with a path bound to the NavigationFlow shared instance. The navigationDestination modifier uses the enum to determine which view to display.</p><h3>Key Features of This Approach</h3><p><strong>1. Enum-Driven Navigation:</strong> By using enums to represent navigation destinations, you simplify the management of your app’s screens and ensure consistency across your codebase.</p><p><strong>2. Centralized View Handling:</strong> The Destination class provides a single location for mapping enum cases to their corresponding views, making it easier to maintain and update your view hierarchy.</p><p><strong>3. ObservableObject for State Management:</strong> NavigationFlow uses ObservableObject to keep the UI in sync with the current navigation state, ensuring smooth and responsive navigation.</p><p>This streamlined approach enhances code maintainability and scalability, making it ideal for managing complex navigation flows in SwiftUI.</p><p>Feel free to integrate this pattern into your SwiftUI projects and see how it simplifies your navigation logic. Happy coding! :)</p><p>#SwiftUI #iOSDevelopment #MobileAppDevelopment #Swift #Programming</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=391cbe420ec3" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>