<?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 Varun Mehta on Medium]]></title>
        <description><![CDATA[Stories by Varun Mehta on Medium]]></description>
        <link>https://medium.com/@catchvarun25?source=rss-f9e3fbe3abfd------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*qwJmyOptsrOXBvSTqbu65g@2x.jpeg</url>
            <title>Stories by Varun Mehta on Medium</title>
            <link>https://medium.com/@catchvarun25?source=rss-f9e3fbe3abfd------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 12:26:46 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@catchvarun25/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[Configure multiple Transformer using metro]]></title>
            <link>https://medium.com/@catchvarun25/configure-multiple-transformer-using-metro-b55ca2f526bd?source=rss-f9e3fbe3abfd------2</link>
            <guid isPermaLink="false">https://medium.com/p/b55ca2f526bd</guid>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[react-native-development]]></category>
            <dc:creator><![CDATA[Varun Mehta]]></dc:creator>
            <pubDate>Sat, 31 Aug 2024 15:30:34 GMT</pubDate>
            <atom:updated>2024-08-31T15:49:30.420Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>ReactNative Project Setup</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*xdG_MvrkiZ-_mT5xhCPIjQ.png" /></figure><p>While setting up your ReactNative project you may come up with situation where you may want to configure metro.configto add support for multiple transformer e.g. <br>react-native-sass-transformer: that allows you to use Sass (Syntactically Awesome Style Sheets) in your React Native project.<br>react-native-svg-transformer that allows you to use SVG files like React component in your React Native projects.</p><h4>NOT WORKING ❌</h4><p>Solution that comes right away to our mind is to create multiple configurations and merge it with default like below:</p><pre>const { getDefaultConfig, mergeConfig } = require(&quot;@react-native/metro-config&quot;);<br><br>/**<br> * Metro configuration<br> * https://reactnative.dev/docs/metro<br> *<br> * @type {import(&#39;metro-config&#39;).MetroConfig}<br> */<br><br>module.exports = (async () =&gt; {<br>  const defaultConfig = await getDefaultConfig(__dirname);<br><br>  //Configuration#1<br>  const sassConfig = {<br>    transformer: {<br>      babelTransformerPath: require.resolve(&quot;react-native-sass-transformer&quot;),<br>    },<br>    resolver: {<br>      sourceExts: [...defaultConfig.resolver.sourceExts, &quot;scss&quot;, &quot;sass&quot;],<br>    },<br>  };<br><br>//Configuration#2 <br>  const svgConfig = {<br>    transformer: {<br>      babelTransformerPath: require.resolve(&quot;react-native-svg-transformer&quot;),<br>    },<br>    resolver: {<br>      assetExts: defaultConfig.resolver.assetExts.filter(<br>        (ext) =&gt; ext !== &quot;svg&quot;<br>      ),<br>      sourceExts: [...defaultConfig.resolver.sourceExts, &quot;svg&quot;],<br>    },<br>  };<br><br>   //Merge it with default<br>  return mergeConfig(defaultConfig, [sassConfig, svgConfig]);<br>})();</pre><p>But this doesn’t work because we can not use separate transformers for handling .scss and .svgasbabelTransformerPath can only be set once in the configuration file so there needs to create a custom transformer that will handle transformation based on the file extension.</p><h4><strong>Working Solution </strong>✅</h4><p>Highlighting steps for the solution that works for me:</p><p><strong>Step 1:</strong> Lets create a new file custom-transformer.js in your project’s root directory:</p><pre>const sassTransformer = require(&quot;react-native-sass-transformer&quot;);<br>const svgTransformer = require(&quot;react-native-svg-transformer&quot;);<br>const metroBabelTransformer = require(&quot;metro-react-native-babel-transformer&quot;);<br><br>module.exports.transform = function ({ src, filename, options }) {<br>  if (filename.endsWith(&quot;.scss&quot;) || filename.endsWith(&quot;.sass&quot;)) {<br>    return sassTransformer.transform({ src, filename, options });<br>  }<br>  if (filename.endsWith(&quot;.svg&quot;)) {<br>    return svgTransformer.transform({ src, filename, options });<br>  }<br>  return metroBabelTransformer.transform({ src, filename, options });<br>};<br></pre><p>Step 2: Now update our metro.config.js to use this custom transformer:</p><pre>const { getDefaultConfig, mergeConfig } = require(&quot;@react-native/metro-config&quot;);<br><br>/**<br> * Metro configuration<br> * https://reactnative.dev/docs/metro<br> *<br> * @type {import(&#39;metro-config&#39;).MetroConfig}<br> */<br><br>module.exports = (async () =&gt; {<br>  const defaultConfig = await getDefaultConfig(__dirname);<br><br>  const customConfig = {<br>    transformer: {<br>      babelTransformerPath: require.resolve(&quot;./custom-transformer&quot;),<br>    },<br>    resolver: {<br>      assetExts: defaultConfig.resolver.assetExts.filter(<br>        (ext) =&gt; ext !== &quot;svg&quot;<br>      ),<br>      sourceExts: [...defaultConfig.resolver.sourceExts, &quot;scss&quot;, &quot;sass&quot;, &quot;svg&quot;],<br>    },<br>  };<br><br>  return mergeConfig(defaultConfig, customConfig);<br>})();</pre><p>This above solution works for me. I hope it will save your time.<br>And please do let me know through comments if in case you have any better solution than this.</p><p>Cheers!<br>Happy Decoding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b55ca2f526bd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kick start with Machine Learning in iOS apps.]]></title>
            <link>https://medium.com/@catchvarun25/kick-start-with-machine-learning-in-ios-apps-d90b88a24de7?source=rss-f9e3fbe3abfd------2</link>
            <guid isPermaLink="false">https://medium.com/p/d90b88a24de7</guid>
            <category><![CDATA[swiftui]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[coreml]]></category>
            <category><![CDATA[coremltools]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <dc:creator><![CDATA[Varun Mehta]]></dc:creator>
            <pubDate>Mon, 03 Jun 2024 03:43:49 GMT</pubDate>
            <atom:updated>2024-09-02T04:27:50.627Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><strong>CoreML</strong>: Learning with Experience</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*TJY_gDQxLdeLodiC" /></figure><h3>Whats is Machine Learning?</h3><p>Machine Learning is a sub-branch of AI where we create and train models by feeding sufficient, accurate and relevant data to machine learning algorithm.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/830/1*CqOfXgrVcCKq3Wf1uAc2GQ.png" /><figcaption><em>Model creation process</em></figcaption></figure><p>Then we evaluate created model using test data set and check the prediction and accuracy level. We keep repeating this process until we get the right prediction with acceptable accuracy. It takes a lot of time and effort to come up with the final successful model.</p><p>Apple has saved above effort for us by providing lot of successfully trained models at <a href="https://developer.apple.com/machine-learning/">Apple Developer</a> websites and a framework (<em>CoreML</em>) to use them.</p><h3>What is CoreML?</h3><p>CoreML is a machine learning framework provided by Apple to integrate machine learning model into iOS apps. It is the foundation framework for all domain specific ML framework and functionalities provided by Apple.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/716/1*AhOC3B9luaRLYmumHNu9Rw.png" /></figure><p>*<a href="https://developer.apple.com/documentation/vision">Vision</a> for analysing images. *<a href="https://developer.apple.com/documentation/naturallanguage">Natural Language</a> for processing text<br>*<a href="https://developer.apple.com/documentation/speech">Speech</a> for converting audio to text. *<a href="https://developer.apple.com/documentation/soundanalysis">Sound Analysis</a> for identifying sounds in audio.</p><h4>How CoreML works?</h4><p>CoreML uses a specific model format (.mlmodel) to run machine learning models on Apple devices.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/852/1*rhf_pw7LzgddxLV1Oext3g.png" /></figure><p>So, in order to work with CoreML, machine learning model has to be compatible with CoreML. Third party models like <em>TensorFlow</em>, <em>Caffe</em> , <em>ONNX</em> has to be converted to .mlmodel using <strong><em>coremltools</em></strong>to make them compatible with CoreML.</p><h4>Now, Let’s see CoreML in action</h4><p>Let’s create a simple app to demonstrate CoreML in working. We will try to use <em>MobileNetV2</em> <em>(Image Classification)</em> model provided by Apple to detect the object in an image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/198/1*_JG__h4CbrzIhimPhd7VXQ.gif" /><figcaption>Image Classification App</figcaption></figure><p><strong><em>Step#1:</em></strong><em> Create a new iOS project and name it as ImageClassification.</em></p><p><strong><em>Step#2:</em></strong><em> Add CoreML model to Xcode Project:-<br></em>Download <em>MobileNetV2</em>model from<em> </em><a href="https://developer.apple.com/machine-learning/models/">here</a> and drag it to your iOS Project. Soon after you drag a model to Xcode project, it automatically generates a wrapper class to use that model. Go to your Xcode project then select the model just dragged to see the wrapper class details.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vCD4tz_kyxcmKDKqalx8rQ.jpeg" /></figure><p>In most of the cases we use this wrapper class to get observations. However in some cases when there is a need to access underlying <em>MLModel</em> interface, just use wrapper class’s <em>model</em> property. Every model has predefined Input and Output to use it. e.g. <em>MobileNetV2</em>model as below input &amp; output</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/461/1*Ygb3n2MblJqnYDkqjO570g.png" /><figcaption><em>MobileNetV2 Input and Output</em></figcaption></figure><p>We can either directly use <em>MobileNetV2 </em>wrapper class<em> </em>and handle input/output formatting ourselves ( like resizing image to 224 x 224 or converting UIImage to CVPixelBuffer etc.) OR just use <em>Vision</em> framework which takes image classification model as input and provide observations (<em>VNClassificationObservation</em>) to us. In this example I used Vision framework to show top two observations on screen.</p><p><strong><em>Step#3</em></strong><em> Working with Vision framework: -<br></em>Let me highlight <strong>4 main</strong> steps involved in working with <em>Vision</em> framework which internally interacts with CoreML to make observations. Same steps are used in working with any other image classification framework.</p><p>Below code is also available in sample code provided by Apple. I just copy pasted it in my sample project and made small changes as per my need.</p><p><strong>#3.1:</strong> Initialise <em>Vision</em> core model <em>VNCoreMLModel </em>by providing an instance of model wrapper class <em>MobileNetV2.</em></p><pre>class ImagePredictor {<br>    private static let imageClassifier = createImageClassifier()<br>    /// - Tag: name<br>    static func createImageClassifier() -&gt; VNCoreMLModel {<br>        // Use a default model configuration.<br>        let defaultConfig = MLModelConfiguration()<br>        <br>        // Create an instance of the image classifier&#39;s wrapper class.<br>        let imageClassifierWrapper = try? MobileNetV2(configuration: defaultConfig )<br>        <br>        guard let imageClassifier = imageClassifierWrapper else {<br>            fatalError(&quot;App failed to create an image classifier model instance.&quot;)<br>        }<br>        <br>        // Get the underlying model instance.<br>        let imageClassifierModel = imageClassifier.model<br>        <br>        // Create a Vision instance using the image classifier&#39;s model instance.<br>        guard let imageClassifierVisionModel = try? VNCoreMLModel(for: imageClassifierModel) else {<br>            fatalError(&quot;App failed to create a `VNCoreMLModel` instance.&quot;)<br>        }<br>        <br>        return imageClassifierVisionModel<br>    }<br>}</pre><p><strong>#3.2</strong> Create Vision image request <em>VNImageBasedRequest</em> (sub-class of <em>VNRequest</em>) using the Vision Core Model created in step 1.</p><pre>/// Generates a new request instance that uses the Image Predictor&#39;s image classifier model.<br>private func createImageClassificationRequest() -&gt; VNImageBasedRequest {<br>    // Create an image classification request with an image classifier model.<br>    let imageClassificationRequest = VNCoreMLRequest(model: ImagePredictor.imageClassifier,<br>                                                         completionHandler: visionRequestCompletionHandler)<br>    imageClassificationRequest.imageCropAndScaleOption = .centerCrop<br>    return imageClassificationRequest<br>}</pre><p><strong>#3.3:</strong> Create vision request handler <em>VNImageRequestHandler</em>and execute the request created in step 2.</p><pre>// Start the image classification request.<br>func makePredictions(for photo: UIImage, completionHandler: @escaping ImagePredictionHandler) throws {<br>    guard let photoImage = photo.cgImage else {<br>            fatalError(&quot;Photo doesn&#39;t have underlying CGImage.&quot;)<br>    }<br>    let orientation = CGImagePropertyOrientation(photo.imageOrientation)<br>    let imageClassificationRequest = createImageClassificationRequest()<br>    predictionHandlers[imageClassificationRequest] = completionHandler<br>    // Create vision request handler<br>    let handler = VNImageRequestHandler(cgImage: photoImage, orientation: orientation)<br>    let requests: [VNRequest] = [imageClassificationRequest]<br>    // Start the image classification request.<br>    try handler.perform(requests)<br>}</pre><p><strong>#3.4:</strong> Once the request is completed, <em>visionRequestCompletionHandler</em> will be called where we used map function to cast observations to prediction structures that will be eventually passed to view to handle display.</p><pre>// Cast the request&#39;s results as an `VNClassificationObservation` array.<br>guard let observations = request.results as? [VNClassificationObservation] else {<br>    // Image classifiers, like MobileNet, only produce classification observations.<br>    // However, other Core ML model types can produce other observations.<br>    // For example, a style transfer model produces `VNPixelBufferObservation` instances.<br>    print(&quot;VNRequest produced the wrong result type: \(type(of: request.results)).&quot;)<br>    return<br>}<br>// Create a prediction array from the observations.<br>predictions = observations.map { observation in<br>    // Convert each observation into an `ImagePredictor.Prediction` instance.<br>    Prediction(classification: observation.identifier,<br>               confidencePercentage: observation.confidencePercentageString)<br>}</pre><p>Thats it! Simple, Isn’t it? Check out the complete source code <a href="https://github.com/catchvarun25/ImageClassification">here</a> and do some experimentation. Try to change the model from <em>MobileNetV2 </em>to any other image classification models like <em>InceptionV3 </em>or<em> EfficientNet </em>and compare the results and performance.</p><p>Now, lets look at some of the benefits and limitations of using CoreML</p><h4>Benefits of CoreML</h4><ol><li><em>Offline Support</em>: As the model is in person’s device there is no need of network to perform the prediction.</li><li><em>Data Privacy: </em>As no data leaves app so person’s data is completely private.</li><li><em>Optimised Performance:</em> for iOS devices through leveraging the CPU, GPU, and Neural Engine while minimizing its memory footprint and power consumption.</li></ol><h4>Disadvantages of CoreML</h4><ol><li><em>Increased App Size</em>: Some models size can be very large which eventually can increase the download size of the app and reduce the app performance on lower model of iOS devices.</li><li><em>Out dated Models may require app update</em>: CoreML has limited support for on-device model training. It provides support to update only certain types of model. So, there may be a need to update an app to update the model.</li><li><em>Limited third party model support</em>: As of now CoreML only supports conversion from limited number of model formats life <em>TensorFlow</em>, <em>Caffe, Keras </em>etc.</li></ol><h3>What are the alternatives?</h3><p>So, What if we can’t use CoreML because of its limitations or our special use-case.</p><p>We can choose below options based on our need.</p><ol><li>[On-Device] <a href="https://www.tensorflow.org/lite/guide/ios"><em>TensorFlow Lite:</em></a> is a lightweight version of TensorFlow designed for mobile and embedded devices.</li><li>[On-Device] <a href="https://onnxruntime.ai/docs/build/ios.html"><em>ONNX Runtime:</em></a> (Open Neural Network Exchange) Runtime is a cross-platform, high-performance scoring engine for Open Neural Network Exchange (ONNX) models.</li><li>[On-Server] <a href="https://firebase.google.com/docs/ml-kit/ios/use-custom-models"><em>Firebase ML Kit:</em></a> Firebase ML Kit provides ready-to-use APIs for common machine learning tasks and supports custom model deployment.</li></ol><h4>How to convert third party model to CoreML model (.mlmodel)</h4><p>Highlighting steps below to quickly onboard your third party model with CoreML</p><blockquote><strong>Step#1</strong> Install CoreML python tools provide by Apple <a href="https://apple.github.io/coremltools/docs-guides/source/installing-coremltools.html">here</a>.</blockquote><pre># https://apple.github.io/coremltools/docs-guides/source/installing-coremltools.html<br>pip install coremltools</pre><blockquote><strong>Step#2</strong> Download and convert third party models. Please refer the links provided in comments, in case you get any error.</blockquote><p><strong>Example#1</strong> Converting TensorFlow ‘model’ to CoreML model</p><pre># https://apple.github.io/coremltools/docs-guides/source/convert-tensorflow.html<br>import coremltools as ct<br>coreml_model = ct.convert(tensor_flow_model)<br>coreml_model.save(&quot;core_ml_model.mlmodel&quot;)</pre><p><strong>Example# 2</strong> Converting Caffe ‘model’ to CoreML model</p><pre># https://www.wwt.com/article/convert-a-caffe-model-to-core-ml-format<br>import coremltools as ct<br># You may need .prototxt and class_labels.py depending upon the model<br># that you are converting from.<br>coreml_model = ct.converters.caffe.convert(&#39;&lt;path_to_.caffemodel&gt;&#39;, &#39;&lt;path_to_.prototxt&gt;&#39;)<br>coreml_model.save(&quot;core_ml_model.mlmodel&quot;)</pre><h3>Where to go from here?</h3><p>I would like to provide some extra toppings over this article that you can try to create and train models from scratch using <a href="https://developer.apple.com/machine-learning/create-ml/"><em>CreateML</em></a> tool provided by Apple.</p><p><em>Pre-requisite:</em><br><strong>1.</strong> MacOS Mojave &amp; Xcode 10<br>which I think most of us already have now a days.<br><strong>2.</strong> Data Set: To train and evaluate image classification model. For image data set you can use<em> </em><a href="https://www.image-net.org/"><em>ImageNet</em></a>. <br><strong>3.</strong> Use<em> </em><a href="https://developer.apple.com/machine-learning/create-ml/"><em>CreateML</em></a> tool provided by Apple to create and train your model.</p><p>I hope this article has given you a good taste of integrating Machine Learning models in iOS apps and may help you kick start your journey in creating innovative ML based iOS apps.</p><p>Give me a 👏🏼 if you like this article.<br>Attaching complete <a href="https://github.com/catchvarun25/ImageClassification">source code</a> for your reference.</p><p>Thank You! 🙏<br>See you in next learning.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d90b88a24de7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[MVVM with SwiftUI + Combine]]></title>
            <link>https://medium.com/@catchvarun25/mvvm-with-swiftui-combine-51edb1a011ce?source=rss-f9e3fbe3abfd------2</link>
            <guid isPermaLink="false">https://medium.com/p/51edb1a011ce</guid>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[swiftui]]></category>
            <category><![CDATA[combine]]></category>
            <category><![CDATA[unsplash-api]]></category>
            <category><![CDATA[mvvm-ios]]></category>
            <dc:creator><![CDATA[Varun Mehta]]></dc:creator>
            <pubDate>Mon, 15 Aug 2022 14:31:32 GMT</pubDate>
            <atom:updated>2023-06-03T04:33:41.235Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Create Reactive Functional app using SwiftUI declarative syntax and power of Combine</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_Ccd_oKA5OAQP-5cvV53XQ.png" /><figcaption>Thats me before SwiftUI and Combine</figcaption></figure><p>Since the introduction of SwiftUI and Combine by Apple in 2019 it has been challenge to write modular, scalable and testable code. In this article, I would not like to focus more on what is MVVM and why we should use MVVM as it will make this article unnecessarily big. I would rather like to focus on How to implement MVVM design pattern using SwiftUI and Combine.</p><p>So, by the end of this article you will be able to</p><ul><li>Understand how to implement a simple Photo Gallery app where we would be fetching some list of photos using <a href="https://unsplash.com/documentation"><strong>Unsplash public APIs</strong></a>, downloading the pictures and displaying it on our mobile screen.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/200/1*VXI_l-Afe7b29XprcFL1-g.gif" /><figcaption>Final App Preview</figcaption></figure><ul><li>Design your reusable View using SwiftUI declarative syntax.</li><li>Create previews for View, dependant upon external data, by mocking ViewModel. Same approach can be used to mock classes while writing test cases.</li><li>Use MVVM design pattern to separate UI from the logic part.</li><li>Bind View with ViewModel using SwiftUI and combine framework.</li></ul><p>Let’s get started. Before moving ahead, I’m assuming that reader has basic understanding of SwiftUI and Combine.</p><h4>Quick refresher on MVVM:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/617/1*VksZf23rfyU8frXhdKLw_w.png" /><figcaption>MVVM Rules</figcaption></figure><p>Follow the steps below to get started.</p><ul><li>Download complete source code from <a href="https://github.com/catchvarun25/PhotoGallery/archive/refs/heads/main.zip">here</a> or you can clone from this Github <a href="https://github.com/catchvarun25/PhotoGallery">link</a>.</li><li>Create your app on <a href="https://unsplash.com/developers"><strong>Unsplash Developers portal</strong></a> and get your <strong>AccessKey</strong> to fetch list of photos. Signup if you do not have any account with Unsplash. Then go to <strong>Your Apps -&gt; New application -&gt; Accept Terms -&gt; </strong>Provide<strong> Name </strong>and<strong> Description </strong>for your application -&gt; <strong>Create. </strong>Now go to the keys section of your application and copy <strong>Access Key.</strong></li><li>Replace the value of <em>UNSPLASH_CLIENT_ID </em>inside<em> UAT.xcconfig</em> file with your AccessKey from the previous step.</li></ul><p>Now you will be able to build and run the project . Let’s go through the code. It’s a small 2 pages application. Landing view is <em>PhotoListView</em> where showing list of images downloaded using Unsplash APIs. And on selecting any image, moving to image details view i.e <em>PhotoDetailsView.</em></p><p>Let’s dig into the MVVM implementation for <em>PhotoListView.</em></p><h3>View</h3><p>As per the definition of MVVM, view should be as dumb as possible. It means it should not contain any logic part, it should only be responsible to render data whatever <em>ViewModel</em> has passed to it and send all user events to ViewModel to handle.</p><p>Here <em>PhotoListView </em>only<em> doing below </em><br>-&gt; Sending <em>fetchPhotoList</em> request to <em>ViewModel</em> on view load.<br>-&gt; Display response from <em>ViewModel </em>on request completion without calling any method on View to re-render. This magic can be achieved using new SwiftUI features.</p><p>Open the <em>PhotoListView</em> class in source code.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ceb16ea93bbbfc5812a53edbb39ad889/href">https://medium.com/media/ceb16ea93bbbfc5812a53edbb39ad889/href</a></iframe><p>By quickly looking at this code, we can say that View is not holding any logic to fetch, parse or format response data. Perfect! 👍</p><p>Lets break the code to understand more:</p><p>#1 <em>PhotosListViewModelInterface </em>Creating a ViewModel interface helps us in follow <strong>D</strong> of SOLID principles i.e. injecting View’s dependency on ViewModel. Dependency can be mock ViewModel to help write UI test-cases or create preview for our view.</p><p>#2 <em>PhotoListView</em> holding a strong &amp; private reference to its <em>ViewModel</em>. Here using SwiftUI <em>@StateObject</em> property wrapper to define ViewModel property inside View. It means that <em>PhotoListView</em> will be observing the changes in ViewModel instance assigned to this property.</p><p>In order to be observed by View, ViewModel should conform to <em>ObservableObject </em>protocol and need to define some properties inside ViewModel class with <em>@Published</em> property wrapper. So, whichever property we mark as <em>@Published</em> property will trigger the view re-render on any change.</p><blockquote><strong>Please Note:</strong> I have used <em>@StateObject</em>instead of <em>@ObservedObject</em>so that ownership of the ViewModel object lies with PhotoListView. It’s up-to you how you want to build the relationship to avoid retain cycle.</blockquote><p>#3 <em>LazyVGrid</em> to display collection of images. It’s available from iOS14+ and benefit of this over normal Grid container is that it creates child views only when SwiftUI needs to display them.</p><p>#4 <em>makePhotoDetailsView</em> is static function to create <em>PhotoDetailsView</em>, associate ViewModel with it and returns the View.</p><p>#5 <em>PhotoCard</em> (subview) of <em>PhotoListView </em>is watching the changes in <em>PhotoListViewModel</em> through @ObservedObject property, inside <em>PhotoCard,</em> referring to the instance of <em>PhotoListViewModel</em> passed to it. So any change in <em>PhotoListViewModel</em> instance will get cascade to <em>PhotoCard </em>view<em> </em>also and helps re-render it.</p><p>#6 This is the point where chain reaction starts. Fetching list of photos on load of <em>PhotoListView.</em></p><p>#7 Mocking ViewModel <em>MockPhotoListViewModel</em> to provide mock data to create preview for my view depending upon response from web APIs.</p><h3>ViewModel</h3><p>It’s where we keep most of our logic. It take events from View and take required action like consuming APIs, receiving response, reformatting the data received before passing it over to View. And it should not hold reference to View. To avoid ViewModel class becoming massive in size, we can create some utility classes and hold their strong reference inside ViewModel. By this we may be able to reuse the code also across multiple ViewModels.</p><p>Previously, we have seen how ViewModel binds to View. Now let’s see how ViewModel observe to APIs response in a <em>Reactive Functional Programming</em> way using Combine framework provided by Apple.</p><blockquote><strong>Please Note</strong>: Types like ObservableObject and property wrapper like @Published, @ObservedObject, that we used above for binding between ViewModel and View, also using Combine framework under the hood.</blockquote><p>Let’s start by looking at the code of PhotoListViewModel.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d1eb44010a337ce73ecb289d37333b0b/href">https://medium.com/media/d1eb44010a337ce73ecb289d37333b0b/href</a></iframe><p>ViewModel contains all the logic of consuming web services, parsing response and formatting or saving data before passing it over to View.</p><p>Lets break the code:</p><p>#1 As mentioned before, <em>PhotoListViewModel</em> confirms to ObservableObject protocol.</p><p>#2 Defined <em>photoList</em> and <em>imageList</em> properties with <em>@Published</em> property wrapper which will just add the publisher wrapper over the property. <br><em>photoList </em>stores the list of PhotoModel where as<em> imageList </em>is used to cache downloaded images. However, please note <em>NSCache </em>will be the better option for caching.</p><p>#3 ViewModel class having private and strong reference to utility class of type <em>PhotosFetchable,</em> used for consuming APIs. <em>PhotosFetchable</em> is a protocol defining interface for my API manager class (<em>PhotosAPI</em>). It defines functions returning <em>AnyPublisher,</em> which can be subscribed in our ViewModel (<em>PhotoListViewModel</em>) to receive all events (response/error) after we hit an API.</p><pre>protocol PhotosFetchable {<br>func fetchPhotosList() -&gt; AnyPublisher&lt;[PhotoModel], APIError&gt;<br>func downloadPhoto(_ url: String) -&gt; AnyPublisher&lt;Data,APIError&gt;<br>}</pre><p>Defining this interface for our API manager class helps us in mocking actual APIs and return mock json for UnitTesting.</p><p>#4 Saving collection of subscription to retain them until ViewModel is alive and dispose once ViewModel released from memory.</p><p>#5 &amp; #6 Are typical example of how to use Combine (Reactive Functional Programming) to consume web-services. <a href="https://developer.apple.com/documentation/combine/future/sink(receivevalue:)"><em>Sink</em></a> is one of the most handy operator provide by combine to create a closure based subscriber and subscribe to publisher.</p><h3>Model</h3><p>It stores actual data returned as a response from web-services. It may contain some logic of data formatting also, but try to avoid it, if possible.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1ae1c2bb840a631455bf0fe1843ab355/href">https://medium.com/media/1ae1c2bb840a631455bf0fe1843ab355/href</a></iframe><p>If you look at above code, there is nothing special in it. It defines typical struct model conforming to <em>Codable</em> protocol. The only difference is <em>PhotoModel</em> confirming to <em>Identifiable</em> Protocol also. Its only requirement is that there must be property named <strong>id </strong>which should contains unique identifier. Its only benefit is that we no need to tell <strong>for-each loop</strong> which property to use as unique identifier in SwiftUI.</p><h3>That’s it!!</h3><p>You may go through the code to decode <em>PhotoDetailsView</em> at your end. Sharing with you Github <a href="https://github.com/catchvarun25/PhotoGallery">link</a> of the complete source code. Please do rate ⭐ if you like it and leave your comments here. There are many other ways to implement MVVM in swift but with SwiftUI and Combine it looks more clear, cleaner and easy to implement. I hope it may help you to get started. Happy Decoding!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=51edb1a011ce" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Migration of UIWebView to WKWebView]]></title>
            <link>https://medium.com/@catchvarun25/migration-of-uiwebview-to-wkwebview-9945ebb70e15?source=rss-f9e3fbe3abfd------2</link>
            <guid isPermaLink="false">https://medium.com/p/9945ebb70e15</guid>
            <category><![CDATA[wkscriptmessagehandler]]></category>
            <category><![CDATA[wkusercontentcontroller]]></category>
            <category><![CDATA[wkwebview]]></category>
            <category><![CDATA[wkhttpcookiestore]]></category>
            <category><![CDATA[swift]]></category>
            <dc:creator><![CDATA[Varun Mehta]]></dc:creator>
            <pubDate>Sat, 29 Aug 2020 15:48:12 GMT</pubDate>
            <atom:updated>2020-08-29T15:48:12.424Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Common issues that comes while migration in Hybrid or Cross-platform application and how to resolve them.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9kmEzwRgIdhHiPuYg0KBDw.jpeg" /><figcaption>Plan your migration</figcaption></figure><h4>How WKWebView is different from UIWebView?</h4><p>Before deep diving into migration process, its always better to know what has been changed in new WKWebView. It helps you to plan your migration and to avoid unwanted errors.</p><blockquote>Please Note: The App Store will no longer accept new apps using UIWebView as of April 2020 and app updates using UIWebView as of December 2020.</blockquote><p><strong>[1]</strong> WKWebView is part of WebKit framework whereas UIWebView is part of UIKit framework. So you need to import WebKit before using it.</p><p><strong>[2]</strong> Most important one is that WKWebView runs on separate process as of your application. Which means that it can load web pages faster than UIWebView and also compromised web content doesn’t affect your app.</p><p><strong>[3]</strong> As WKWebView runs on separate process, use Nitro Javascript engine, use asynchronous calls to communicate with Javascript. This makes it faster to load web content as compared with UIWebView.</p><p><strong>[4]</strong> WKWebView is more secure than UIWebView. <em>XSS </em>(Cross-site scripting) <em>in </em><em>WKWebView is more restricted because </em><em>AllowUniversalAccessFromFileURLs and </em><em>AllowFileAccessFromFileURLs are off by default.</em></p><p><strong>[5]</strong> WKWebView has its own cookie storage (<a href="https://developer.apple.com/documentation/webkit/wkhttpcookiestore?language=objc">WKHTTPCookieStore</a>) and doesn’t share its cookie storage with your app or any other web view inside your app.</p><p><strong>[6] </strong>WKWebView provides extra features like supporting server side authentication challenge. Where as with UIWebView we need to do it using custom URLProtocol. If you want to know how, you can find it <a href="https://medium.com/@catchvarun25/ssl-certificate-pinning-with-uiwebview-dcdc742e4d01">here</a>.</p><p>Ok! let’ s start the migration process.</p><p>Quickly change the delegates mapping as per the below table</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K8KzkF-0NurQ3RZXRcR-Hg.png" /></figure><h3>Challenges &amp; Resolution</h3><blockquote><strong>1. Managing Cookies</strong></blockquote><p>As mentioned in change #5 above, from iOS 11 onward each WKWebView will have its own cookie storage <a href="https://developer.apple.com/documentation/webkit/wkhttpcookiestore">(WKHTTPCookieStore</a>), separate from its parent app and other WKWebView instance used inside the application. To access this dedicated store, it provides one configuration class,WKWebViewConfiguration.</p><p>Using the WKWebViewConfiguration class, you can not only access WKHTTPCookieStore object but also you can determine how soon a webpage is rendered, how media playback is handled, the granularity of items that the user can select, and many other options.</p><pre><strong>Please Note: </strong>WKWebViewConfiguration instance can ONLY be provided at the time when WKWebView is first initialised. So if you have taken an IBOutlet for WKWebView, you can create a new instance of WKWebView and replace it with existing one like in Solution2 of Issue#1 below.</pre><p><strong><em>Issue#1:</em></strong><em> Not able to set cookies while loading request with WKWebView.</em></p><p><strong><em>Description: </em></strong>If you are loading some external web page inside your web view that is using cookies from your application cookie storage. So after updating the UI component from UIWebView to WKWebView inside your UIViewController , you can encounter this error because of the reason described in #5 above.</p><p><strong><em>Solution1</em>:</strong> To manipulate with cookie store, WKWebView has provided couple of methods <em>setCookie(_:completionHandler:), </em>getAllCookies(_:), delete(_:completionHandler:). So, You can set the cookies to your web-views default configuration object before loading request. Please note, all these methods comes with completion handler and these methods need to be called on main thread.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4_DtImoPZrX7DB-D5cWVqA.png" /></figure><p><strong><em>Solution2: </em></strong>What if you want to initialise your WKWebView with your custom WKWebViewConfiguration object.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sthLyglCtc6FjhkusFAnuw.png" /></figure><p>As setCookie comes with a completion handler so using DispatchGroup here to load my WebView after all setCookie operations completed.</p><p><strong><em>Issue#2: </em></strong><em>Cookies inside WKHTTPCookieStore is going out of sync with HTTPCookieStorage of application.</em></p><p><strong><em>Use-case:</em></strong> Maintaining a user session between app and website (opening inside WKWebView) by setting a session cookies before loading a website. These session cookies are used by server to help identify a unique user and grant access. However when user moves back from website to app, session getting timed out because cookies inside WKHTTPCookieStore is going out of sync with the cookies inside HTTPCookieStorage used by parent app.</p><p><strong><em>Solution:</em></strong> Cookies need to be synched back to HTTPCookieStorage for every change in cookie inside WKHTTPCookieStore to maintain session between app and website opened inside WKWebView. We can achieve this like below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RBnUwtyKqP742zpynNdIUQ.png" /></figure><p>It would be better if you find the cookie with name insideHTTPCookieStorage and replace it with the updated one.</p><blockquote><strong>2. Javascript Interaction</strong></blockquote><p>Please check the usage of UIWebView in your cross platform application. Because if you are using UIWebView in application to execute ONLY Javascript code then migrating to WKWebView is not advisable. Instead, use <a href="https://developer.apple.com/documentation/javascriptcore">JavaScriptCore</a> framework, which provides the ability to evaluate JavaScript programs from within Swift, Objective-C, and C-based apps.</p><p><strong>Injecting Javascript</strong></p><p>Still if it is required to migrate to WKWebView then you can update you existing code as mentioned in Solution#1 below:</p><p>1. Use evaluateJavaScript method over WKWebView instance.This is same as stringByEvaluatingJavaScriptFromString method of UIWebView.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5s3BKutO9oejlRBVcVswuw.png" /></figure><p>However this solution is not advisable with WKWebView as we are using delay with this solution and also do not have much control over other configuration settings provided by WKWebViewConfiguration. Please check other better solution below.</p><p>2.Use<a href="https://developer.apple.com/documentation/webkit/wkuserscript">WKUserScript</a>. It is object containing custom javascript that can be loaded at time defined as part of this enum <a href="https://developer.apple.com/documentation/webkit/wkuserscriptinjectiontime">WKUserScriptInjectionTime</a>. For this we can make use of WKUserContentController property of WKWebViewConfiguration instance that is assigned while WKWebView creation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/200/1*87x0F4M0_pG065xbomIkMA.png" /></figure><p>This is very powerful way of injecting your javascript even when you do not have access to the source code of webpage. It is a big step ahead from UIWebView.</p><p>In below example it is demonstrated how can we change the background colour for google.com home page.</p><p>Save below script as sample.js in your Xcode project.</p><pre>var myStyle = document.createElement(“style”);</pre><pre>myStyle.textContent = ‘body { background-color: coral; } ‘;</pre><pre>document.documentElement.appendChild(myStyle);</pre><p>And call below function from viewDidLoad() of your ViewController containing WKWebView.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d849f37a95bd890ca5e3842b90b8d71d/href">https://medium.com/media/d849f37a95bd890ca5e3842b90b8d71d/href</a></iframe><p><strong>Javascript Callbacks</strong></p><p>In order to receive a message from Javascript to native code, you may have used UIWebViewDelegate method <em>webView(_: shouldStartLoadWith request: navigationType:) </em>to intercept the url schemes OR you may have used<em> </em><a href="https://developer.apple.com/documentation/javascriptcore">JavaScriptCore</a> framework where you may have struggled to get JSContext for your UIWebView.</p><p>But now with WKWebView it is very easy to call a swift method from Javascript code by using WKUserContentController class which is defined as a property to WKWebViewConfiguration instance. You can add WKScriptMessageHandler to WKWebView using WKUserContentController instance as defined below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mbpw1JKv7JlDOnoBoDxIcg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YRjt7t0_O2ZZnQzQVLFCOQ.png" /></figure><p>Please make sure to use the same name of the handler in your Javascript code as defined in Swift code. It will look like below in Javascript code:</p><pre>window.webkit.messageHandlers.javascriptHandler.postMessage(&quot;My Custom Message&quot;);</pre><h3>That’s it!!</h3><p>I hope this article will help you some how in solving some of your migration issues. Do let me know about your challenges faced.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9945ebb70e15" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SSL Certificate Pinning with UIWebView]]></title>
            <link>https://medium.com/@catchvarun25/ssl-certificate-pinning-with-uiwebview-dcdc742e4d01?source=rss-f9e3fbe3abfd------2</link>
            <guid isPermaLink="false">https://medium.com/p/dcdc742e4d01</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[ssl]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[iphone]]></category>
            <dc:creator><![CDATA[Varun Mehta]]></dc:creator>
            <pubDate>Sun, 24 May 2020 04:40:53 GMT</pubDate>
            <atom:updated>2020-05-24T04:40:53.156Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Intercepting URL request using URLProtocol.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iPHeg2t0jUKEbJzv2aTD3w.png" /></figure><p>Through this article i would like to share how you can trust/cancel a server certificate while trying to access a web page from a UIWebView component inside an application. As you know, UIWebView doesn’t provide any delegate methods like WKWebView, where you can handle your server trust challenge. As well as Apple is also insisting on using WKWebView because it uses Nitro, a faster javascript engine and it is more secure than UIWebView.</p><p>Now you will ask : <em>“Why not use WKWebView in place of UIWebView for handling server trust ?”</em> Answer is: <strong>Yes!</strong> but there can be many reasons of sticking with UIWebView, like:</p><ul><li>Existing legacy code and you don’t want to migrate your code as of now.</li><li>If you are working on Hybrid applications like me and facing various migration issues.</li><li>Existing WKWebView issues. You can track some issues <a href="https://issues.apache.org/jira/browse/CB-14180?jql=project%20%3D%20CB%20AND%20labels%20%3D%20wkwebview-known-issues">here</a>.</li></ul><p>Moreover this article is not only about implementing SSL cert pinning with UIWebView. You will find it later that you can achieve many more things using the same approach.</p><p>Before starting, i would to give a refresher over SSL &amp; Cert Pinning, which we can use to avoid man-in-middle attacks. If you already know about it, you can directly jump to Step#3, implementation with UIWebView.</p><ol><li><strong>What is SSL ?</strong></li></ol><p>SSL (Secure Socket Layer) is a protocol to provide a secure communication between client and server. Below figure shows the steps involved in SSL handshake.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l4ZoNSjB9_T6No3rKkRxEw.png" /></figure><p>Although above SSL communication is considered pretty much secure and unbreakable in realistic time frames, but man-in-the-middle (MITM) attack still poses an actual threat. MITM is like someone can come in between and impersonate as a trusted server. It means using ARP cache poisoning &amp; DNS spoofing anyone can read all the data flows between client and server. You can easily reproduce MITM using any web debugger tools like <a href="https://www.charlesproxy.com/">Charles</a> or <a href="https://portswigger.net/burp">Burp</a>. So, to overcome this problem we use certificate pinning.</p><p><strong>2. What is SSL certificate pinning?</strong></p><p>It is technique in which we keep the target server’s certificate in our app bundle and while connecting to the server we compare the server certificate with the certificate saved in our app bundle. If it matched, we trust the server and initiate the connection. As an example , i highlighted below how we used to do it in Swift whenever server trust challenge is thrown while consuming web services using URLSession:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/96a0582e2f893ef78130aa788955f493/href">https://medium.com/media/96a0582e2f893ef78130aa788955f493/href</a></iframe><p>So by cert pinning we can restrict the number of signing authorities trusted by your client application. And also your app will not expose your API contract through proxies applications such as Charles. One thing to keep in mind is that your app will stop working if server certificate changes, in this case, you need to update your app.</p><p><strong>3. Certificate pinning with UIWebView?</strong></p><p>Now we learned about SSL Certificate Pining and how we can handle trust challenge in Swift. It is time to check how to do it while accessing a web page inside UIWebView component.</p><p>What UIWebView actually use to display a page, a URL. And UIWebView internally use NSURLConnection class to process all url request. So, we need to do below to handle trust in outgoing url request through UIWebView.</p><ol><li>Intercept the request.</li><li>Make mutable copy of the request.</li><li>Handle it with NSURLConnection/URLSession.</li><li>Forward the messages to Apple’s <a href="https://developer.apple.com/documentation/foundation/url_loading_system#//apple_ref/doc/uid/10000165-BCICJDHA">URL Loading System</a>.</li></ol><p>For this <strong>URLProtocol </strong>class is like rosetta stone for us. With URLProtocol you can define your custom URL schemes and help you redefine how URL Loading System works.</p><p>Whenever URL Loading System receives a URL request, it searches for any registered protocol handler which can handle the request. Any custom registered protocol handler can tell the URL Loading System that it can handle the request using canInit(with request:)method.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uwbDJoT7dYcidsfvchtpbQ.png" /></figure><p>If you noticed above, we are using a helper method from URLProtocol, called property(forKey: in:). This method queries for a custom property that can be applied on any NSMutableURLRequest.</p><p>You can register your custom protocol handler by adding below line of code in your application(_:didFinishLaunchingWithOptions:) method in AppDelegate.swift class.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QWFI0KwmX3ZJzf7OSoP84Q.png" /></figure><p>If none of the registered handlers can handle the request, then it will be handled by URL Loading System. Now add below three methods to your custom protocol class.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oIr7urPl9HwupkSqI8nO2g.png" /></figure><p>+canonicalRequest(for request:)is a class methods that your custom protocol must implement. Your output request must be semantically equals to the input request. But at bare minimum, it should return the input request.</p><p>-startLoading and -stopLoading are instance methods used by URL Loading System to tell your protocol to start and stop loading a request.</p><p>In -startLoading we intercept initial URL request, create mutable copy of it and start loading data using URLSession class. Don’t forget to set an identifier to your mutable request otherwise you will land up in infinite loop of url request.-stopLoading this is where your url loading can be cancelled.</p><p>Congrats! till now we have successfully completed our step#1,2,3 as mentioned above. So for Step#4 we can use URLProtocol <strong>client</strong> property. Which provides us various APIs to relay URLSessionDataDelegate messages back to URL Loading system.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-bT7Env0tTvJ0suE8mubbw.png" /></figure><p>SSL certificate pinning is now a cake walk for us. Just copy paste the code as we did above in urlSession(_session: didReceive challenge: completionHandler) delegate method.</p><p>Please check this <a href="https://developer.apple.com/library/archive/technotes/tn2232/_index.html">documentation</a> if you would like to change trust evaluation and to do some customisation.</p><h3><strong>That’s it!!</strong></h3><p>This is just a tip of an iceberg of many things that we can achieve with custom URLProtocol. For example</p><ul><li>You can implement your custom web browser application.</li><li>You can intercept all URL request in your application and add certain header or cookies from single place.</li></ul><p>Go ahead and explore more.</p><p>I hope this article helps you some how in understanding the core concept of using URLProtocol in our application.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dcdc742e4d01" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>