<?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 Ahmed Iqbal on Medium]]></title>
        <description><![CDATA[Stories by Ahmed Iqbal on Medium]]></description>
        <link>https://medium.com/@mh.ahmediqbal?source=rss-d4e7b705812c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*3ln-cJgziyUXhxzBCUyukQ.jpeg</url>
            <title>Stories by Ahmed Iqbal on Medium</title>
            <link>https://medium.com/@mh.ahmediqbal?source=rss-d4e7b705812c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 03:54:53 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mh.ahmediqbal/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[Fastlane: A quick guide to save time]]></title>
            <link>https://levelup.gitconnected.com/fastlane-a-quick-guide-to-save-time-789f393cb5b7?source=rss-d4e7b705812c------2</link>
            <guid isPermaLink="false">https://medium.com/p/789f393cb5b7</guid>
            <dc:creator><![CDATA[Ahmed Iqbal]]></dc:creator>
            <pubDate>Sun, 09 Mar 2025 11:12:35 GMT</pubDate>
            <atom:updated>2025-03-12T00:42:45.745Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-dhdrLsmKK_EHZH2eGw5aw.jpeg" /></figure><p>You have landed here because you want to get rid of repeatedly uploading builds on Testflight or share the builds with QA by some other medium and want to save time by making a mechanism which automates these redundant steps. If that’s the case then you’ve landed at the right place and here I’ll show you a quick guide on using Fastlane.</p><p>There are multiple ways through which you might want to setup your Fastlane integration for instance you might want to keep the codebase of Fastlane explicit to a specific machine or you can set up the integration in codebase in a way that every developer can independently generate builds via Fastlane on their own machines. Whatever the scenario is, this integration guide will cover it entirely and you can adjust it based on your preference. The major benefit of setting up Fastlane explicitly in a separate machine(which is dedicated for uploading builds only) is that you can keep secret keys explicitly in that machine rather than keeping them distributed among all devices of peers.</p><h3><strong>Step 1 Installing Fastlane</strong></h3><p>My preference of installing fastlane is via Homebrew as its the least problematic. Open up terminal and run the following command:</p><blockquote>brew install fastlane</blockquote><p>Now from your terminal navigate to the project directory and run the following command:</p><blockquote>fastlane init</blockquote><p>Upon running this command you will be getting prompt for automating screenshots, beta deployemnt and app store deployment which for now you can ignore and choose option of manually setting up the project. Upon this selection Fastlane will generate a folder named “fastlane” which will contain file named <strong>Fastfile </strong>and <strong>Appfile.</strong></p><h3><strong>Step 2 Authentication with Apple Services</strong></h3><p>There are several methods of authentication with Apple Services but my preference is authenticate via Appstore Connect API (which Apple announced at WWDC18 and is an official public API used to manage app metadata, pricing and availability, provisioning, and more).</p><h4><strong>Creating an App Store Connect API Key</strong></h4><ol><li>Create a new App Store Connect API Key in the <a href="https://appstoreconnect.apple.com/access/users">Users and Access</a> page</li></ol><ul><li>For more info, go to the <a href="https://developer.apple.com/documentation/appstoreconnectapi/creating_api_keys_for_app_store_connect_api">App Store Connect API Docs</a></li><li>Open the Integrations tab, select App Store Connect API, and create a new &quot;Team Key&quot; using the + button. Note that if you can’t see the App Store Connect API tab, this means you don&#39;t have permission yet. Please refer to the docs above to know how to get this permission</li><li>Give your API Key an appropriate role for the task at hand. You can read more about roles in <a href="https://developer.apple.com/support/roles/">Permissions in App Store Connect</a></li><li>Note the Issuer ID as you will need it for the configuration steps below</li></ul><p>2. Download the newly created API Key file (.p8)</p><ul><li>This file cannot be downloaded again after the page has been refreshed</li></ul><h4><strong>Using an App Store Connect API Key</strong></h4><p>The API Key (located in the .p8) file, the key id, and the issuer id are needed to create the JWT token for authorization. There are multiple ways that these pieces of information can be input into <em>fastlane</em>.</p><p>Now we have to use action of “app_store_connect_api_key” which takes the key id, the issuer id, and API Key file (.p8) to generate a dictionary/hash used for JWT authorization.</p><pre>lane :release do<br>  api_key = app_store_connect_api_key(<br>    key_id: &quot;D343SF339&quot;,<br>    issuer_id: &quot;6052b2fe-62a8-4acb-29be-165ac6425141&quot;,<br>    key_filepath: &quot;./AuthKey_D284SF139.p8&quot;,<br>    duration: 1200, # optional (maximum 1200)<br>    in_house: false # optional but may be required if using match/sigh<br>  )<br><br>  pilot(api_key: api_key)<br>end</pre><h3>Step 3 Building &amp; Deploying App</h3><h4>Building App</h4><p>When working within huge teams where you are required to give builds to QA individually you might want to share them using means other than Testflight and you might want to customize the profile in order for them to test a certain use case on a certain profile and environment so lets first develop an action which would help us generating .ipa based on our own profile preference.</p><pre>lane :make_build do |options|<br>    build_app(<br>      scheme: &quot;MediumAppSample&quot;,<br>      output_name: build_name + &quot;.ipa&quot;,<br>      export_method: &quot;development&quot;  <br>      export_options: {<br>        &quot;signingStyle&quot; =&gt; &quot;manual&quot;,<br>        provisioningProfiles: {<br>          &quot;com.mediumsampleapp.md&quot; =&gt; &quot;dc9f0013-e567-4f3c-aecb-780363b69861&quot;,<br>      }<br>    )<br>  end</pre><p>Above snippet is giving us complete option of generating build using export option of our own preference alongwith directory where you want to save the builds generated from Fastlane. You can set “export_method” to “ad-hoc” based on your preference the type of build you want to export and within that its up to you with which provisioning profile you want while generating build.</p><pre>lane :upload_to_testflight do |values|<br>  increment_build_number # Optional: Increment the build number<br>  make_build(build_name: values[build_name]) # Build the app<br>  upload_to_testflight # Upload to TestFlight<br>end</pre><p>Now everthing is setup and you can use above lane to build the app and upload it to the linked Testflight account, one thing to note while adding keys to the lane is that you might want to put sensitive data within environment variables instead of writing them down directly and pushing them to remote repository as it can cause huge problem if its accessed by unauthorized user so always remember to put your keys in .env file and then use it accordingly within your lane.</p><h3>Additional Content (Uploading builds on s3 bucket)</h3><p>In cases where the frequency of sharing development builds with QA teams or for external testing is high and your team has decided to use s3 bucket for that purpose then this additional content will help you out in setting up and automate Continous Deployment your build delivery to s3 bucket. This is additional content for covering this use case and can be skipped if you are not following this approach within your team.</p><p>To upload an iOS build to an AWS S3 bucket using Fastlane, you can use the aws_s3 plugin. Below is a step-by-step guide to set up and use this lane:</p><h3>1. Install the aws_s3 Plugin</h3><p>First, you need to install the aws_s3 plugin for Fastlane:</p><pre>fastlane add_plugin aws_s3</pre><p>This will add the plugin to your Pluginfile and install it.</p><h3>2. Configure AWS Credentials</h3><p>Ensure you have your AWS credentials set up. You can configure them using environment variables or the AWS CLI:</p><h4>Using Environment Variables</h4><p>Set the following environment variables:</p><pre>export AWS_ACCESS_KEY_ID=&#39;your_access_key_id&#39;<br>export AWS_SECRET_ACCESS_KEY=&#39;your_secret_access_key&#39;<br>export AWS_REGION=&#39;your_region&#39;</pre><h4>Using AWS CLI</h4><p>If you have the AWS CLI installed, you can configure your credentials by running:</p><pre>aws configure</pre><h3>3. Create the Fastlane Lane</h3><p>Open your Fastfile and add a new lane to build the iOS app and upload it to S3:</p><pre>platform :ios do<br>  desc &quot;Build and upload iOS app to AWS S3&quot;<br>  lane :upload_to_s3 do<br>    # Increment build number (optional)<br>    increment_build_number<br>    # Build the app<br>    build_app(scheme: &quot;YourAppScheme&quot;)<br>    # Upload to AWS S3<br>    aws_s3(<br>      bucket: &#39;your-s3-bucket-name&#39;,<br>      access_key: ENV[&#39;AWS_ACCESS_KEY_ID&#39;],<br>      secret_access_key: ENV[&#39;AWS_SECRET_ACCESS_KEY&#39;],<br>      region: ENV[&#39;AWS_REGION&#39;],<br>      ipa: lane_context[SharedValues::IPA_OUTPUT_PATH] # Path to the built .ipa file<br>    )<br>  end<br>end</pre><h3>4. Run the Lane</h3><p>To run the lane and upload your app to AWS S3, use the following command:</p><pre>fastlane upload_to_s3</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/999/1*YBLAnnaV1Pdrujhv0MPBGw.png" /></figure><p>All the hassle has been wrapped up entirely to an automated lane and saving your time for all the redundancy of uploading .ipa’s.</p><h3>5. Troubleshooting</h3><p>If you encounter any issues, you can enable verbose logging to get more detailed output:</p><pre>fastlane upload_to_s3 --verbose</pre><p>So that’s it, you are done with your complete setup. I have tried to keep it as simple as possible and have discussed only minor details, however fastlane gives us builtin actions which cover advanced cases as well such as generating test code coverage or running a static analyzer and much more. In case of any questions feel free to reach out to me through the questions section. If you find this helpful then do give it a clap. Cheers!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=789f393cb5b7" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/fastlane-a-quick-guide-to-save-time-789f393cb5b7">Fastlane: A quick guide to save time</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Localization in SwiftUI]]></title>
            <link>https://levelup.gitconnected.com/localization-in-swiftui-644490118a4b?source=rss-d4e7b705812c------2</link>
            <guid isPermaLink="false">https://medium.com/p/644490118a4b</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[localization]]></category>
            <category><![CDATA[xcode]]></category>
            <category><![CDATA[swiftui]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Ahmed Iqbal]]></dc:creator>
            <pubDate>Thu, 07 Dec 2023 10:36:41 GMT</pubDate>
            <atom:updated>2024-01-01T21:33:06.752Z</atom:updated>
            <content:encoded><![CDATA[<p>Hey all, this is a quick walkthrough of implementing localization in SwiftUI for both LTR and RTL languages.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6bEeM1mSbMn0EDjZYn2SIw.jpeg" /></figure><p>No doubt things are much simpler in SwiftUI relative to UIKit but the new framework is in my opinion still a work in progress and sometimes developers get stuck in implementing straightforward tasks. Implementing Localization for left-to-right languages is pretty straightforward and has the same method of implementation as we get in UIKit but the problem arises for right-to-left languages such as Arabic, Hebrew, Persian, etc because for these languages we need to flip the screen from LTR to RTL along with changing the language. In this walkthrough, we will be using String Catalog instead of using the conventional method of Strings File (legacy).</p><h3><strong>First step</strong></h3><p>Create an Xcode project and then add a new file named String Catalog by pressing ⌘ + n and selecting it from the popup alert that appears.</p><h3>Second step</h3><p>Create a swift file and add a LocalizationService class along with an enum in which you can add as many languages as you want.</p><pre>class LocalizationService {<br><br>    static let shared = LocalizationService()<br>    static let changedLanguage = Notification.Name(&quot;changedLanguage&quot;)<br><br>    var language: Language {<br>        get {<br>            guard let languageString = UserDefaults.standard.string(forKey: &quot;language&quot;) else {<br>               var languageCode = &quot;&quot;<br>               <br>                if #available(iOS 16, *) {<br>                   languageCode = NSLocale.current.language.languageCode?.identifier ?? &quot;&quot;<br>                 } else {<br>                    languageCode = NSLocale.current.languageCode ?? &quot;&quot;<br>                }<br>                <br>                if languageCode == Language.arabic.rawValue {<br>                   UserDefaults.standard.setValue(Language.arabic.rawValue, forKey: &quot;language&quot;)<br>                   return .arabic<br>                } else {<br>                   UserDefaults.standard.setValue(Language.english_us.rawValue, forKey: &quot;language&quot;)<br>                   return .english_us<br>               }<br>            }<br>            return Language(rawValue: languageString) ?? .english_us<br>            <br>        } set {<br>            if newValue != language {<br>                UserDefaults.standard.setValue(newValue.rawValue, forKey: &quot;language&quot;)<br>                NotificationCenter.default.post(name: LocalizationService.changedLanguage, object: nil)<br>            }<br>        }<br>    }<br>}<br><br>enum Language: String {<br>    case arabic = &quot;ar&quot;<br>    case english_us = &quot;en&quot;<br>    case ukrainian = &quot;uk&quot;<br>    <br>    var isRTL: Bool {<br>        self == .arabic<br>    }<br>}</pre><h3>Third Step</h3><p>Now create a singleton class named Appstate (you can name it whatever you want) which you will be using for the persisting LTR and RTL state of the app. This will be used initially in our main class in which we will be globally passing it down our environment attribute as you can see below</p><pre>class AppState: ObservableObject {<br>    static let shared = AppState()<br>    @Published var isRTL = false<br>}<br><br>@main<br>struct LocalizationExampleApp: App {<br>    <br>    private var language = LocalizationService.shared.language<br>    @ObservedObject var appState = AppState.shared<br>    <br>    init() {<br>        appState.isRTL = language == .english_us ? false : true<br>    }<br>    var body: some Scene {<br>        WindowGroup {<br>            ContentView().id(appState.isRTL)<br>                .environment(\.layoutDirection, appState.isRTL ? .rightToLeft : .leftToRight)<br>        }<br>    }<br>}</pre><h3>Fourth Step</h3><p>Remember that every string which we will placing in the app will now be used as key for which we will need to provide translation for other languages in our String Catalog file, just click on the String Catalog file and you’ll get an interface like this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YeSEH1F4qUwBiJgJDNx9ww.png" /></figure><p>Place your key values here against every language which you want</p><h3>Fifth Step</h3><p>Fifth and final step is to select the area where you want to place the button which will change/toggle the language of the app and for that simply use the Appstate class that we created above and change the variable state globally</p><pre>if AppState.shared.isRTL {<br>    LocalizationService.shared.language = .english_us<br>    AppState.shared.isRTL = false<br>} else {<br>    LocalizationService.shared.language = .arabic<br>    AppState.shared.isRTL = true<br>}</pre><p>Below is the view of the app which will show you how the transition from LTR to RTL will look like</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*KOou-49tfELCAa8B0oax9g.gif" /></figure><p>Below is link for the sample application which you can use to understand this article more easily. If you find this helpful then do give it a clap. 😊</p><p><a href="https://github.com/mh-ahmediqbal/localization">GitHub - mh-ahmediqbal/localization: This is sample app which demonstrates switching application state from LTR to RTL</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=644490118a4b" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/localization-in-swiftui-644490118a4b">Localization in SwiftUI</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Embed a Unity Game in an iOS App]]></title>
            <link>https://medium.com/better-programming/embed-a-unity-game-in-ios-app-7c2bd4cddb6f?source=rss-d4e7b705812c------2</link>
            <guid isPermaLink="false">https://medium.com/p/7c2bd4cddb6f</guid>
            <category><![CDATA[unity]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[game-development]]></category>
            <category><![CDATA[xcode]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Ahmed Iqbal]]></dc:creator>
            <pubDate>Fri, 15 Jul 2022 07:57:57 GMT</pubDate>
            <atom:updated>2022-07-19T06:00:02.247Z</atom:updated>
            <content:encoded><![CDATA[<h4>Connect an exported Unity project</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YIQSpMCeR58DNCI3IewqMQ.jpeg" /></figure><p>Recently I came across a task where I had to embed a Unity AR module into an existing iOS app.</p><p>Upon reading Unity’s documentation it turns out that since v2019.3 Unity provides support for loading and unloading a Unity game from a native iOS or Android app through their <a href="https://unity.com/features/unity-as-a-library">Unity as a Library</a> feature.</p><p>Although the documentation itself was pretty comprehensive still there were some points that were missing which is why I have made this walkthrough so let’s get started.</p><h3>Create an iOS project</h3><p>First, create an empty iOS project inside a workspace. A simple way to do this is to first create an empty Xcode project, and then go to File → Save As Workspace. Let’s name both the project and the workspace SwiftUnity.</p><p>Important: Make sure you select Storyboard as the Interface, these steps are needed even if you want to use SwiftUI as they are essential to get the Unity integration working.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VSGobOPpqifbY_rq6BKwog.png" /></figure><p>Note that if you wanna go for the SwiftUI project, then don’t forget to set the minimum iOS deployment target to 13.0.</p><h3><strong>Setting up Unity Project</strong></h3><p>Since we’re focusing majorly on iOS here so I won’t dive deep into explaining Unity and would focus on only the part where we will be unloading the Unity module from the iOS app.</p><p>However, one significant step which we need to follow is to call <a href="https://docs.unity3d.com/ScriptReference/Application.Unload.html">Application.Unload()</a> in the section where we want to go back to our iOS app from Unity.</p><p>So basically what this function does is that it doesn’t entirely destroy the unity instance rather it retains some space within the memory so that if the user wants to open the Unity module multiple times then it wouldn’t require loading the Unity module entirely rather it would utilize the existing retained memory.</p><p>Now assuming that within the Unity module you have placed an exit point where you want to close it and this exit point is linked with some button within the Unity module. So simply call <a href="https://docs.unity3d.com/ScriptReference/Application.Unload.html">Application.Unload()</a> as shown below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/40b26ac0717d8b79df93a55c50e7acc0/href">https://medium.com/media/40b26ac0717d8b79df93a55c50e7acc0/href</a></iframe><p>Now once you are done with above step open the Unity project, go to<strong> </strong>File → Build Settings. Here you will need to change the Platform from PC, Mac &amp; Linux Standalone to iOS, then click on the Switch Platform button. You’ll need to wait a bit for Unity to recompile.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pWWvKyHvJTUxjqJWPJrNQg.png" /></figure><p>Time to export our Unity project as an iOS project. You don’t need to change any of the settings, just click Build. You will export the Unity project in a folder called UnityBuild. So now your folder structure should look like this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cvkWM7S2aHTDoDjs9-iS-Q.png" /></figure><h3>Embed Unity in iOS</h3><p>Now the fun part begins when we connect the exported Unity project with our iOS app. Open the swiftUnity.xcworkspace, which currently only contains the SwiftUnity project.</p><p>In Finder, locate the UnityExport project, and drag the<br>Unity-iPhone.xcodeproj file to the workspace.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h14lW4EyG-scNXHbxb8zRw.png" /></figure><p>Now both swiftUnity.xcodeproj and Unity-iPhone.xcodeproj belong to the same workspace. Next, click on swiftUnity project and select the swiftUnity target.</p><p>From the General menu, scroll down to the Frameworks, Libraries and Embedded Content section. Click on the + button to add a new framework.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*74jGUKBZYRjf9USzno_4DQ.png" /></figure><p>Select UnityFramework.framework from the list and add it to the project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/822/1*sC-dRPuwOZQpesa5UG9Chg.png" /></figure><p>Next, select the Data folder in Unity-iPhone<strong> </strong>project. In the right panel, you will see a “Target Membership”<strong> </strong>section. You need to check the box next to UnityFramework.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2oFBuoKx5PqKC1W9Kpdvqw.png" /></figure><p>Next, open Info.plist and remove the Application Scene Manifest entry. This will temporarily break the app but we’ll resolve it later in the AppDelegate. If you skip this step then you will not be able to go back to your iOS app (upon calling Application.Unload()) once the unity instance launches.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T5w2GkVCBQ_AkXbCKgXAqA.png" /></figure><p>Now create a swift file in swiftUnity<strong> </strong>and name it Unity. Add the following code to that file.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9e399b060863324e50107fec9c2ab44c/href">https://medium.com/media/9e399b060863324e50107fec9c2ab44c/href</a></iframe><p>Open AppDelegate.swift and remove all scene-related functions. We will also need to pass the main app window reference to Unity here since that’s the window we’ll return to once we unload the Unity game.</p><p>After these modifications, your AppDelegate should look like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b80b63649eb366f077fc7a20857848ee/href">https://medium.com/media/b80b63649eb366f077fc7a20857848ee/href</a></iframe><p>Now in your existing Xcode project go the section where you want to open the unity module, in my case I’ll simply put a button on the storyboard and open the unity module to open its IBAction.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c057e697ba788c2927e2cb4d2f36482a/href">https://medium.com/media/c057e697ba788c2927e2cb4d2f36482a/href</a></iframe><p>That’s it, now it’s time to run and test the app.</p><p>Common issues: If Xcode is unable to build the project after following all of the steps above and gives an error saying <em>“No such module UnityFramework”</em>, then simply select UnityFramework from above and press ⌘+B:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ogzTuWDAQnHcdEYOU8QRFw.png" /></figure><p>Once it&#39;s done then select Unity-iPhone and do the same and in the end select back your iOS project i.e swiftUnity in our case and run the project.</p><p>Another important note to keep in mind is to run the project on a real device rather than on a simulator.</p><h3>Final Look</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*1aDbwI2FaCK94M3bDIatjw.gif" /></figure><p><a href="https://github.com/mh-ahmediqbal/embed-unity">GitHub - mh-ahmediqbal/embed-unity: A walkthrough of how we can embed unity in an iOS app</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7c2bd4cddb6f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-programming/embed-a-unity-game-in-ios-app-7c2bd4cddb6f">Embed a Unity Game in an iOS App</a> was originally published in <a href="https://betterprogramming.pub/">Better Programming</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build an App for SpaceX Using Clean Architecture in iOS]]></title>
            <link>https://medium.com/better-programming/clean-architecture-in-ios-a5963e61fd8?source=rss-d4e7b705812c------2</link>
            <guid isPermaLink="false">https://medium.com/p/a5963e61fd8</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Ahmed Iqbal]]></dc:creator>
            <pubDate>Sun, 15 May 2022 12:37:14 GMT</pubDate>
            <atom:updated>2022-07-23T11:03:45.735Z</atom:updated>
            <content:encoded><![CDATA[<h4>Create a launchpad</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5dXhGHkn1wlF0gIm" /><figcaption>Photo by <a href="https://unsplash.com/@ivvndiaz?utm_source=medium&amp;utm_medium=referral">Ivan Diaz</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In this walkthrough, we’ll learn how to use the VIP clean architecture pattern to develop apps for Apple platforms.</p><p>We will develop a Clean SpaceX app where we will be showcasing information regarding the rockets which have been made and experimented with by SpaceX.</p><h3>What is VIP?</h3><p>Compared to MVVM, MVC or VIPER the VIP architectural pattern is one of the least known patterns in iOS development. They’re basically different implementations of Uncle Bob’s Clean Architecture pattern.</p><p>VIP simply stands for View — Interactor — Presenter.</p><p>The VIP architecture for writing clean Swift code was introduced by Raymond Law. He created a <a href="https://clean-swift.com/">clean-swift</a> website where you can read about how to use VIP patterns in UIKit.</p><p>VIP was actually created to fix MVC, or Massive View Controllers, a common problem in UIKit apps where View Controllers become the main object where code is kept and they become drastically huge in that most if not all of your logic is kept within them. This can also cause a lot of issues for you later down the lane when your objective is to expand your app by adding more and more features. Furthermore, VIP is unidirectional which saves up the trouble of getting our code components to be mixed up with each other.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zc81S6SKCmwBCgXVUihrkg.png" /></figure><h4>View</h4><p>The View is generally your app’s UI. It role is to send requests to the interactor every time the user interacts with the UI.</p><h4>Interactor</h4><p>The Interactor takes care of your app’s business logic, such as fetching or sending data from the network or saving data in a database. When the view requests something, the interactor does the processing and sends the result as a response to the presenter.</p><h4>Presenter</h4><p>The Presenter handles the presentation logic. It formats the received data into view models suitable for display and then passes it to the view.</p><h3>Getting started with CleanSpaceX</h3><p>CleanSpaceX is a sample project I created for demonstration of clean architecture’s implementation. It majorly consists of only two Scenes i.e Rockets and RocketDetails.</p><p>Their names are pretty self-explanatory of what purpose they are serving, Rockets Scene is fetching the list of SpaceX rockets along with the details from their <a href="https://github.com/r-spacex/SpaceX-API">open source endpoints</a> and RocketDetails Scene is showing detail of specific selected Rocket.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/514/1*Gr32e2PY8U9rwQ7Pr2VREQ.png" /></figure><p>Here you see the structure of the scene created with each component distinct from one another. So now let’s look at each one of them one by one. Before that take a quick preview of what we are gonna build.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/352/1*PzLzffHjMuK9NruEXWpucQ.gif" /></figure><h3>Models</h3><p>In this component, all of the models related to the desired controller will be saved. It will be of type struct and mostly it will contain Request, Response, and ViewModel structs.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/803fd22b5b8da95976fe99f52247c178/href">https://medium.com/media/803fd22b5b8da95976fe99f52247c178/href</a></iframe><p>In the above model, you can clearly see structs for Request, Response, and ViewModel and from there it makes things pretty obvious.</p><p>The Request would include parameters that need to be sent to any network call (which in our case is to SpaceX). The Response would include parameters that are to be expected in response to our network call and ViewModel is the section where the above parameters are mapped as per use case.</p><h3>Router</h3><p>The router’s job is to perform all tasks related to transitioning and passing data between view controllers.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e72d99f6cfac862c3250a24e8df980dd/href">https://medium.com/media/e72d99f6cfac862c3250a24e8df980dd/href</a></iframe><p>Above we are covering both of the cases where we are not only navigation to another view controller but we are passing some data along to our destination view controller. Note that there are two protocol defined named RocketData Passing and RocketsRoutingLogic.</p><ol><li>RocketDataPassingis a protocol that contains the data that needs to be passed to the destination controller.</li><li>RocketsRoutingLogic is that protocol in which all the methods used for routing are kept.</li></ol><h3>Worker</h3><p>The Worker component handles all the Network requests and responses. The Response struct (which we used in Models) will get the data ready for the Interactor. It will handle the success/error response, so the Interactor would know how to proceed.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ad1f13f9359ab9c3421ea78d69eb5137/href">https://medium.com/media/ad1f13f9359ab9c3421ea78d69eb5137/href</a></iframe><h3>Interactor</h3><p>The interactor is the most significant component of them all and works as a moderator between Worker and Presenter. Initially, it communicates with the ViewController which passes all the Request parameters needed for the Worker. Before proceeding to the Worker, a validation is done to check if everything is sent properly. The Worker returns a response and the Interactor passes that response towards the Presenter.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f5a24e0dbfcd1b0c6c51aa22b67050ff/href">https://medium.com/media/f5a24e0dbfcd1b0c6c51aa22b67050ff/href</a></iframe><p>Here note that a couple of protocols are being used named RocketsDataStore and RocketsBusinessLogic and they serve the following purpose:</p><ol><li>RocketsDataStore — is used for passing data between view controllers</li><li>RocketsBusinessLogic — is used for declaring all the Interactor methods in this protocol, so they can be available for use in the ViewController.</li></ol><h3>Presenter</h3><p>After getting the Response from the Interactor, it’s time to format it into a ViewModel and pass the result back to the ViewController. Presenter will be in charge of the presentation logic. This component decides how the data will be presented to the user.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/87f1bab88607abe313544b59ec3ab423/href">https://medium.com/media/87f1bab88607abe313544b59ec3ab423/href</a></iframe><p>In Presenter there is only one protocol declared which stores the presentation logic methods. In the presentFetchRockets() function a delegate method is being called that is declared in our associated view controller. This is how it connects itself with the view controller.</p><h3>ViewController</h3><p>Now it’s time to see it all work, all the components have been aligned with one another but still, we require one last major step to perform in order for this entire flow to work.</p><p>Here as you can see that a simple table view has been declared along with its delegates which are being used to show fetched API data in the representable form.</p><p>The last step is to trigger the interactor which will eventually start our cycle where a request will be sent and we’ll get back a response from the Presenter. During this time if the user wants to navigate somewhere then we’ll bring the Router into action.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ef4812584c8fa8072776846ddbbef562/href">https://medium.com/media/ef4812584c8fa8072776846ddbbef562/href</a></iframe><h3>Conclusion</h3><p>You can get the entire project from <a href="https://github.com/mh-ahmediqbal/CleanSpaceX">this link</a>. Feel free to play around with it and let me know any recommendations. Please note that we can also install a clean swift template in our Xcode which will allow us to create a complete Scene using the editor.</p><p>For learning how to configure Xcode please <a href="https://medium.com/@mh.ahmediqbal/installing-clean-architecture-template-in-xcode-50b222a93a94">refer</a> to this walkthrough.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a5963e61fd8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-programming/clean-architecture-in-ios-a5963e61fd8">Build an App for SpaceX Using Clean Architecture in iOS</a> was originally published in <a href="https://betterprogramming.pub/">Better Programming</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Installing Clean Architecture Template in Xcode]]></title>
            <link>https://medium.com/virtual-force-inc/installing-clean-architecture-template-in-xcode-50b222a93a94?source=rss-d4e7b705812c------2</link>
            <guid isPermaLink="false">https://medium.com/p/50b222a93a94</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[uikit]]></category>
            <category><![CDATA[apple]]></category>
            <category><![CDATA[architecture]]></category>
            <dc:creator><![CDATA[Ahmed Iqbal]]></dc:creator>
            <pubDate>Sun, 15 May 2022 11:13:05 GMT</pubDate>
            <atom:updated>2022-07-29T06:20:45.102Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*elBO7_jrv_4SulcUo-7fZA.jpeg" /></figure><p><a href="https://clean-swift.com/">Clean architecture</a> is one of the most popular architecture which is being used in developing iOS applications. This walkthrough is going to show you how easily you can install its template within Xcode and start using it in your projects.</p><h4><strong>Download the template file</strong></h4><p>For your utility the template has been uploaded to Google drive and you can download it using <a href="https://drive.google.com/file/d/1qQiKZ5Bw6_xMgTnHf2afoHDwnCrSoL4G/view?usp=sharing">this link</a>.</p><h4><strong>Installing the template file</strong></h4><p>After downloading the file on your device, unzip it and open your Terminal with accessing the root directory of the folder by using cd CleanSwift.</p><p>Now you just need to run the following command make install_templates in order to install it and if you later on decide to uninstall it then run make uninstall_templates.</p><p>In order to verify whether the template was installed successfully or not open up the following path <em>~Library/Developer/Xcode/Templates/File Templates </em>and search for a folder named <em>CleanSwift.</em></p><h4><strong>Creating a New Scene</strong></h4><p>Finally now is the time to view the templates magic in our editor. Open up Xcode and either create a test project or open up an existing one. Now go to <em>File -&gt; New -&gt; File (or press </em>⌘N<em>) </em>and Xcode will open up its template window. Scroll down to the bottom of the list and you would see the <em>CleanSwift </em>section with all the template files. By clicking on the Scene and selecting the desired name, all the files will be created in your project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*szVn3Fa_wPQ9U1gl4OH9yA.png" /></figure><h4><strong>Voila! now you’ve been able to add clean swift template in your Xcode. I hope this walkthrough has helped you out. 👏 or share so others like you can find it.</strong></h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=50b222a93a94" width="1" height="1" alt=""><hr><p><a href="https://medium.com/virtual-force-inc/installing-clean-architecture-template-in-xcode-50b222a93a94">Installing Clean Architecture Template in Xcode</a> was originally published in <a href="https://medium.com/virtual-force-inc">Virtual Force Inc.</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>