<?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 Pavel Vashkel on Medium]]></title>
        <description><![CDATA[Stories by Pavel Vashkel on Medium]]></description>
        <link>https://medium.com/@vshkl?source=rss-3a94394efd76------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*tSQdv5ZSVWObqo00wMvpuw.jpeg</url>
            <title>Stories by Pavel Vashkel on Medium</title>
            <link>https://medium.com/@vshkl?source=rss-3a94394efd76------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 09:15:19 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@vshkl/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[API calls with Retrofit and Either type]]></title>
            <link>https://medium.com/@vshkl/retrofit-arrow-tk-either-4cb20c1a2f09?source=rss-3a94394efd76------2</link>
            <guid isPermaLink="false">https://medium.com/p/4cb20c1a2f09</guid>
            <category><![CDATA[arrow]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[retrofit]]></category>
            <category><![CDATA[kotlin]]></category>
            <dc:creator><![CDATA[Pavel Vashkel]]></dc:creator>
            <pubDate>Wed, 16 Nov 2022 21:58:45 GMT</pubDate>
            <atom:updated>2023-12-21T21:42:59.692Z</atom:updated>
            <content:encoded><![CDATA[<h3>API calls with Retrofit and Arrow-Kt</h3><p>A simple way to handle API error payload with <strong>Retrofit</strong> the same way as the success one.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2Pqc03kt5N63svi3" /><figcaption>Photo by <a href="https://unsplash.com/@lindseyduce?utm_source=medium&amp;utm_medium=referral">Lindsey Duce</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>It is very easy to use <strong>Retrofit</strong> for calling API and converting <em>successful </em>responses to a model. However, it becomes a bit less trivial when it comes to error responses. For instance, validation error after submitting a form. <strong>Retrofit</strong> threats such cases as exceptions and will throw <strong>HttpException</strong> in that case.</p><pre>retrofit2.HttpException: HTTP 400 Bad Request</pre><p>So, it is needed to catch it, get a payload, and convert it to a desired model. Not terrible, but might be better, probably.</p><p>Ideally, it would’ve been nice to make <strong>Retrofit</strong> handle payloads of error responses the same way as success ones. So there is either a success model or an error model. Luckily, it can be achieved by using an <strong>Either</strong> type from <strong>arrow-kt</strong> library, and an <strong>EitherCallAdapterFactory</strong> that will tell <strong>Retrofit</strong> how to use it. Eventually, an API method will look like this:</p><pre>@POST(&quot;sign-up&quot;)<br>suspend fun signUp(<br>    email: String,<br>    password: String,<br>): Either&lt;ErrorResponse, SuccessResponse&gt;</pre><p>Later on, such <strong>Either</strong> result can be “folded” via <strong>.fold(::ifLeft, ::ifRight)</strong> and process either of the cases however needed.</p><p>More details can be found in the <a href="https://github.com/vshkl/either-api-sample">sample app on GitHub</a>.</p><p>Consider checking other parts of <a href="https://github.com/arrow-kt/arrow">Arrow-Kt</a>.</p><h3>Links</h3><ul><li><a href="https://github.com/square/retrofit">square/retrofit: A type-safe HTTP client for Android and the JVM</a></li><li><a href="https://github.com/arrow-kt/arrow">arrow-kt/arrow: Λrrow — Functional companion to Kotlin’s Standard Library</a></li><li><a href="https://github.com/vshkl/either-api-sample">Sample app</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4cb20c1a2f09" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Handle drag-and-drop with Epoxy]]></title>
            <link>https://medium.com/@vshkl/handle-drag-and-drop-with-epoxy-ea90e9493dab?source=rss-3a94394efd76------2</link>
            <guid isPermaLink="false">https://medium.com/p/ea90e9493dab</guid>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[drag-and-drop]]></category>
            <category><![CDATA[recyclerview]]></category>
            <category><![CDATA[epoxy]]></category>
            <dc:creator><![CDATA[Pavel Vashkel]]></dc:creator>
            <pubDate>Sun, 15 Nov 2020 14:52:58 GMT</pubDate>
            <atom:updated>2020-11-15T14:52:58.168Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*6uxatcnOT8i199oyP7CnHg.gif" /></figure><p>There is a great library made by Airbnb called <a href="https://github.com/airbnb/epoxy">Epoxy</a> which helps to build complex screens using <a href="https://developer.android.com/guide/topics/ui/layout/recyclerview">RecyclerView</a> in a declarative way. That’s the story about how to implement a handler drag-and-drop with it.</p><h3>Item models</h3><p>First of all let’s create two models for items to be shown in the list: header and row.</p><h4>HeaderEpoxyModel</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/289b7f7d9a1223b4fd6be25a0e18df35/href">https://medium.com/media/289b7f7d9a1223b4fd6be25a0e18df35/href</a></iframe><h4>RowEpoxyModel</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/105019b28c5d93333e4f5f0ed5742ecb/href">https://medium.com/media/105019b28c5d93333e4f5f0ed5742ecb/href</a></iframe><h3>Controller and callback adapter</h3><p>Once we’re done with models, let’s setup Epoxy controller and callback adapter to handle callbacks from it.</p><h4>CallbackAdapter</h4><p>This is a simple interface with only one method in our case. onDragStart will be used to tell that the drag initiated from the handler view of the row model.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4297d2610f8db14caae462c5cb7dd1fd/href">https://medium.com/media/4297d2610f8db14caae462c5cb7dd1fd/href</a></iframe><h4>EpoxyController implementation</h4><p>Here we describe how our screen backed by the Epoxy will look like and handle certain event list drag start in our case.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7f9c1edcce4b4034adb1bf4a4daf9c5b/href">https://medium.com/media/7f9c1edcce4b4034adb1bf4a4daf9c5b/href</a></iframe><h3>Touch interactions</h3><p>Now we need to deal with drag-and-drop. To implement the drag-and-drop logic using a handler view instead of the default behavior of activating drag-and-drop after a long press on the item, we need to implement a custom EpoxyModelTouchCallback and a RecyclerView.SimpleOnItemTouchListener.</p><h4>EpoxyModelTouchCallback implementation</h4><p>Subclassing EpoxyModelTouchCallbackwill allows us to do certain tweaks like disabling long-press drag behavior and setting up desired drag directions: ItemTouchHelper.UP<em> </em>and ItemTouchHelper.DOWN in our case<em>.</em></p><p>Also, here we can get moving and shifting row ids from the models to publish them do needed manipulations to the data to commit the drag.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d1512b2121e84e6d202e80666692b502/href">https://medium.com/media/d1512b2121e84e6d202e80666692b502/href</a></iframe><h4>RecyclerView.SimpleOnItemTouchListener implementation</h4><p>To start drag manually using touch helper we need to know the view holder we’ve just touched. Since there are several view holders exist in the Epoxy list, we need to filter out some of them. We will do that using the touchedPosition later.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c1f0ec703adc3e0ebd89f2217b744ef7/href">https://medium.com/media/c1f0ec703adc3e0ebd89f2217b744ef7/href</a></iframe><h3>Connecting things up</h3><p>Now it’s time to wire all the things together in the MainActivity. Everything is pretty straightforward here. In the onDragStart method, we getting the desired view holder under the current touch position filtering out unwanted view holder types so the drag starts only for the row model view holder.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/45879ac9b8436166d7b2d97f1a5fd3b8/href">https://medium.com/media/45879ac9b8436166d7b2d97f1a5fd3b8/href</a></iframe><p>That’s it. Hope someone will find it useful. Full code can be found in <a href="https://github.com/vshkl/EpoxyDNDExample">this repo</a> on my Github.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ea90e9493dab" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Structuring the app navigation]]></title>
            <link>https://medium.com/@vshkl/structuring-react-native-navigation-da77820d587c?source=rss-3a94394efd76------2</link>
            <guid isPermaLink="false">https://medium.com/p/da77820d587c</guid>
            <category><![CDATA[react-native-navigation]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Pavel Vashkel]]></dc:creator>
            <pubDate>Tue, 25 Dec 2018 13:28:21 GMT</pubDate>
            <atom:updated>2020-08-19T17:01:25.437Z</atom:updated>
            <content:encoded><![CDATA[<h3>Structuring app navigation</h3><h4>With the react-native-navigation by Wix</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1FzquKucMhArcVKu" /><figcaption>Photo by <a href="https://unsplash.com/@amyames?utm_source=medium&amp;utm_medium=referral">Amy Elting</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>The story of the Navigation 🗺</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/401/1*U11ovcSwQlMvcj7egt-_-w.png" /><figcaption>react-native-navigation logo by <a href="https://wix.github.io/react-native-navigation">Wix</a></figcaption></figure><p>By default <a href="https://facebook.github.io/react-native/"><em>react-native</em></a> doesn’t come with any navigation solution out of the box. Even though there is a recommenced one —<a href="https://reactnavigation.org/"><em>react-navigation</em></a>, there are a bunch of other possible ways to answer the “How to navigate?” question. Most of them are made in pure JS, which is not bad, but if your desire is to have a truly native navigation you’ve got used to in either Android or iOS, you’ll probably end up with the <a href="https://wix.github.io/react-native-navigation"><em>react-native-navigation</em></a><em> </em>(RNN for the sake of simplicity) by Wix.<br>This is a great library, however the there is a problem… 🤔</p><h3>The problem 🚧</h3><p>Apart of quiet complex <a href="https://wix.github.io/react-native-navigation/#/docs/Installing">installation</a> process, RNN has quite a cumbersome API for describing screen’s <a href="https://wix.github.io/react-native-navigation/#/docs/layout-types">layouts</a>. The screen’s layout should be described via deeply nested JS objects and arrays, which is fairly natural in the JS world, yet it’s quite hard to visually “parse” it in code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*LkZWXcmxMIeOCen77w75tQ.png" /><figcaption>App navigation structure explained</figcaption></figure><p>The thing is that when either pushing a new screen or showing a modal one, you ought to pass an object with an almost complete screen’s layout description, which could become huge for a complex screen especially with additional styling options.</p><h3>The solution💡</h3><p>But fear not! Due to the fact that everything is described by the object, we can easily extract certain parts of the layouts in order to reuse them further.</p><p>Let’s go straight to the solution I came up with. Here is the overall structure of the <strong>navigation</strong> module:</p><pre><strong>src/navigation</strong><br>├── index.js<br>├── common.js<br>├── parts.js<br>├── views.js<br>└── screens.js</pre><p>Let’s see what’s in there:</p><h4><strong><em>common.js</em></strong></h4><p>In here we will store all the common navigation actions which could be reused across the app. Those could be tab switching logic, logic for redirecting the user to the certain place in the app in case of login out and so on and so forth.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bc913b094d0bec07ad90e59df09301ca/href">https://medium.com/media/bc913b094d0bec07ad90e59df09301ca/href</a></iframe><h4><strong><em>parts.js</em></strong></h4><p>That’s the place where small parts of the screens’ layouts belong to. Here we can store bottom tabs, buttons, header components or a side menu toggle button (a.k.a “hamburger”) as in the example below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9daa5b028be82e953f610266c3be3dad/href">https://medium.com/media/9daa5b028be82e953f610266c3be3dad/href</a></iframe><h4><strong><em>views.js</em></strong></h4><p>And here is the place for our layout’s components. They are an almost ready screens’ layouts and could later be placed in different containers: a stack, a bottom or top tabs or side menus.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a6052c465f7defb2e363bc57bf9a6fe2/href">https://medium.com/media/a6052c465f7defb2e363bc57bf9a6fe2/href</a></iframe><h4><strong><em>screens.js</em></strong></h4><p>And the screens finally. The containers we’ve been talking earlier. Here we combine all the things together to get the final screen layout to be fed to the RNN.</p><p>Let’s see how the layout for the app with a side menu and bottom tabs could look:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e3490e3db331a22449cdb6b35f3486b6/href">https://medium.com/media/e3490e3db331a22449cdb6b35f3486b6/href</a></iframe><h3>The profit 📈</h3><p>And finally, after all these manipulations we can perform the navigation in a nice and clean way.</p><p>Setting the root layout for the whole app would look just like that:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d1171d2ec0af39465f3cf28dba7ed930/href">https://medium.com/media/d1171d2ec0af39465f3cf28dba7ed930/href</a></iframe><p>and navigating to a new screen:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/54865772ecac02900ac11cf04b63f0de/href">https://medium.com/media/54865772ecac02900ac11cf04b63f0de/href</a></iframe><p>With such an approach we have a single source of truth for all the navigation layouts and common actions and a better separation into small reusable components like parts, views, and screens.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=da77820d587c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Simple iOS release with fastlane]]></title>
            <link>https://medium.com/@vshkl/simple-ios-release-with-fastlane-c4796530fea8?source=rss-3a94394efd76------2</link>
            <guid isPermaLink="false">https://medium.com/p/c4796530fea8</guid>
            <category><![CDATA[fastlane]]></category>
            <category><![CDATA[releases]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[continuous-delivery]]></category>
            <dc:creator><![CDATA[Pavel Vashkel]]></dc:creator>
            <pubDate>Mon, 27 Nov 2017 21:24:32 GMT</pubDate>
            <atom:updated>2019-03-12T16:03:03.877Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ul6pMsylL61T_zWxWURovA.png" /><figcaption>Fastlane logo from <a href="https://github.com/fastlane/fastlane">https://github.com/fastlane/fastlane</a></figcaption></figure><p>While preparing your iOS app for release you will face with a bunch of tedious repetitive procedures like dealing with certificates, provisioning profiles, uploading translations, taking screenshots using all languages supported by the app and so on.<br>Below I’ll tell you about tool called Fastlane which will take care about most of those task for you.</p><h4>Tools overview</h4><p>For building, signing and publishing application we will use following tools:</p><ul><li><strong>produce</strong> for creating new app in Apple Developer Portal and iTunes Connect</li><li><strong>match</strong> for creating certificates and provisioning profiles</li><li><strong>gym</strong> for building and archiving iOS app</li><li><strong>snapshot</strong> &amp; <strong>frameit </strong>for taking screenshots on all supported languages</li><li><strong>precheck</strong> &amp; <strong>deviler </strong>for checking metadata and publishing the app</li></ul><h4>Installation</h4><p>To use fastlane <a href="https://developer.apple.com/download/">XCode</a> and <a href="https://brew.sh/">homebrew</a> need to be installed.</p><pre>$ <strong>xcode-select</strong> --install # Ensure latest XCode command-line tools<br>$ <strong>brew</strong> cask install fastlane</pre><p>It’s recommended to use Gemfile for <strong>Fastlane</strong> dependencies. Also it will speedup fastlane.</p><pre>$ <strong>sudo</strong> <strong>gem install</strong> bundle</pre><p>Create a Gemfile in the root of your project with the following content:</p><pre><strong>source</strong> &quot;https://rubygems.org&quot;<br><strong>gem</strong> &quot;fastlane&quot;</pre><p>Then run:</p><pre>$ <strong>bundle </strong>update</pre><p>Add both <em>Gemfile </em>and <em>Gemfile.lock </em>to version control.</p><p>Navigate to project’s directory and run.</p><pre>$ <strong>bundle exec fastlane</strong> init -u &lt;your-apple-id&gt;</pre><p><strong>Fastlane</strong> will generate a basic configuration and fetch existing metadata from iTunes Connect if there is one. As a result <em>./fastlane</em> directory with <strong>Appfile</strong> and <strong>Fastfile</strong> in it will be created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/857/1*giPz8I_WNBKIUqIcSB7fbA.png" /><figcaption>./fastlane directory created by fastlane init</figcaption></figure><p><strong>Appfile</strong> could look like this.</p><pre><strong>app_identifier</strong> &quot;com.datarockets.CoolApp&quot;<br><strong>apple_id</strong> &quot;your-apple-id&quot;<br><strong>team_id</strong> &quot;YOURTEAMID&quot;</pre><p>In case you have multiple apps and you don’t want to face with “<em>Maximum number of certificates generated</em>” one day, you can use single certificate for all your app. Just specify all your app identifiers as an array like this:</p><pre><strong>app_identifier</strong> [&quot;com.datarockets.AppOne&quot;, &quot;com.datarockets.AppTwo&quot;]</pre><h4>Produce</h4><p><strong>Fastlane produce</strong> allows creating new iOS app in Apple Developer Portal and iTunes Connect from command line. Run following command.</p><pre>$ <strong>bundle exec fastlane</strong> produce -u &lt;your-apple-id&gt; -a &lt;your-app-identifier&gt;</pre><h4>Match</h4><p>Now, when new application was created it’s time to deal with certificates and provisioning profiles. <strong>Fastlane match</strong> allows syncing certificates and provisioning profiles across team using private git repository. <br>First of all creating a separate <strong>private</strong> <strong>git repository</strong> where all certificates and provisioning profiles will be stored. <a href="https://github.com/fastlane/fastlane/tree/master/match#is-this-secure">Is this secure?</a><br>You can use a separate branch for each of your applications. It’s working solution, however, currently I prefer to set <strong>app_identifier </strong>as array.<br>Run following command. It will create match configuration file — <strong>Matchfile</strong> in <em>./fastlane</em> directory.</p><pre>$ <strong>bundle exec fastlane</strong> match init</pre><p><strong>Matchfile</strong> could look like this:</p><pre><strong>git_url</strong> &quot;https://github.com/datarockets/private-repository&quot;<br><strong>git_branch</strong> &quot;your-app-branch&quot;<br><strong>team_id</strong> &quot;YOURTEAMID&quot;<br><strong>username</strong> &quot;your-apple-id&quot;<br><strong>force_for_new_devices</strong> &quot;true&quot;</pre><p>Also you can use <strong>ssh</strong> git url with match. Just amend <strong>git_url </strong>to something like this: <a href="/service/mailto:git@github.com"><em>git@github.com</em></a><em>:datarockets/private-repository.git</em></p><p>Generate certificates, and provisioning profiles using one of the following commands.</p><pre>$ <strong>bundle exec fastlane</strong> match development # For Development<br>$ <strong>bundle exec fastlane</strong> match adhoc       # For Ad-hoc<br>$ <strong>bundle exec fastlane</strong> match appstore    # For App Store<br>$ <strong>bundle exec fastlane</strong> match enterprise  # For Enterprise</pre><p>That’s how private git repository will looks like.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/857/1*-GiNEH9ipKDfmv3yHXqvog.png" /><figcaption>Private git repository with certificates and provisioning profiles</figcaption></figure><p>Now go to <strong>XCode</strong> and select newly created profiles in the signing section.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bnfKXQTkNoANi2UaEFwPTg.png" /><figcaption>Set provisioning profiles in XCode</figcaption></figure><h4>Gym</h4><p>Time to build app! <strong>Fastlane gym</strong> allows to generate a signed iOS app.<br>Following command will create a configuration file — <strong>Gymfile</strong> in <em>./fastlane</em> directory.</p><pre>$ <strong>bundle exec fastlane</strong> gym init</pre><p><strong>Gymfile</strong> could look like this.</p><pre><strong>scheme</strong> &quot;CoolApp&quot;<br><strong>sdk</strong> &quot;iphoneos10.0&quot;<br><strong>include_bitcode</strong> true<br><strong>include_symbols</strong> true<br><strong>clean</strong> true<br><strong>output_directory</strong> &quot;./fastlane/build&quot;<br><strong>output_name</strong> &quot;CoolApp_1.0.0&quot;</pre><p>Now, to build and package our iOS app in <em>.ipa</em> file run the following command.</p><pre>$ <strong>bundle exec fastlane</strong> gym</pre><h4>Snapshot</h4><p>To submit our app for review we need to have at least one screenshot per localization, according to <a href="https://developer.apple.com/library/content/documentation/LanguagesUtilities/Conceptual/iTunesConnect_Guide/Chapters/Properties.html">guidelines</a>. The highest resolution screenshot for each device type can be used. Taking all this screenshot could be a tedious and time-consuming task, especially for numerous of supported languages. <strong>Fastlane snapshot</strong> allows to automate this task.<br>Following command will create a configuration file —<strong>Snapfile</strong> in <em>./fastlane</em> directory.</p><pre>$ <strong>bundle exec fastlane</strong> snapshot init</pre><p><strong>Snapfile</strong> could look like this.</p><pre><strong>devices</strong>([<br>  &quot;iPhone 7 Plus&quot;<br>])<br><br><strong>languages</strong>([<br>  &quot;ru&quot;,<br>  &quot;en&quot;,<br>  &quot;de&quot;,<br>  &quot;fr&quot;,<br>  &quot;it&quot;,<br>  &quot;es&quot;,<br>  &quot;nl&quot;<br>])<br><br><strong>scheme</strong> &quot;CoolApp&quot;<br><strong>output_directory</strong> &quot;./fastlane/screenshots&quot;<br><strong>clear_previous_screenshots</strong> true</pre><p>To run fastlane snapshot create a simple UI test, which will be ran to take desired screenshot. Also, you need to add <em>SnapshotHelper.swift</em> file generated by fastlane snapshot init to your UI test target.</p><pre><strong>import</strong> XCTest<br><br><strong>class</strong> MunchkinLevelCounterUITests: XCTestCase {<br>        <br>    <strong>override func</strong> setUp() {<br>        <strong>super</strong>.setUp()<br><br>        continueAfterFailure = false<br><br>        <strong>let</strong> app = XCUIApplication()<br>        setupSnapshot(app)<br>        app.launch()<br>    }<br>    <br>    <strong>override func</strong> tearDown() {<br>        <strong>super</strong>.tearDown()<br>    }<br>    <br>    <strong>func</strong> testScreenshots() {<br>        <strong>let</strong> app = XCUIApplication()<br>        XCUIDevice.shared().orientation = .portrait<br>        <br>        // Screen number onene<br>        snapshot(&quot;0-First-screen&quot;)<br>        <br>        // Screen number two<br>        app.navigationBars.buttons.element(boundBy: 0).tap()<br>        snapshot(&quot;1-Second-screen&quot;)<br>        <br>        // Screen number three<br>        app.navigationBars.buttons.element(boundBy: 1).tap()<br>        app.alerts.element(boundBy: 0).buttons.element(boundBy: 1).tap()<br>        snapshot(&quot;2-Third-screen&quot;)<br>        <br>        // Retunr to the first screen<br>        XCUIApplication().navigationBars.buttons.element(boundBy: 0).tap()<br><br>        XCTAssert(true)<br>    }<br><br>}</pre><p>All is set up. Now just run following command.</p><pre>$ <strong>bundle exec fastlane</strong> snapshot</pre><h4>Frameit</h4><p>Optionally to make screenshots look better we can use <strong>fastlane frameit</strong> to put screenshots into real device frames. To do so navigate to <em>./fastlane/screenshots</em> directory and run the following command.</p><pre>$ <strong>bundle exec fastlane</strong> frameit gold</pre><h4>Deliver</h4><p>Now fill in all required metadata and upload it along with screenshots and app binary to iTunes Connect. To do so use <strong>fastlane deliver</strong>. App metadata could be placed in <strong>Deliverfile</strong> itself or in separate <em>.txt</em> files in <em>./fastlane/metadata</em> directory. Following command will create configuration file —<strong>Deliverfile</strong> in <em>./fastlane</em> directory.</p><pre>$ <strong>bundle exec fastlane</strong> deliver init</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/857/1*a0WFhGREmPtWktlk9kxk9A.png" /><figcaption>Resulting ./fastlane directory</figcaption></figure><p><strong>Deliverfile</strong> could look like this.</p><pre><strong>app_identifier</strong> &quot;com.datarockets.CoolApp&quot;<br><strong>username</strong> &quot;your-apple-id&quot;<br><strong>ipa</strong> &quot;CoolApp_1.0.0.ipa&quot;<br><strong>app_version</strong> &quot;1.0.0&quot;<br><strong>submit_for_review</strong> false<br><br><strong>screenshots_path</strong> &quot;fastlane/screenshots/&quot;<br><strong>metadata_path</strong> &quot;fastlane/metadata/&quot;<br><strong>app_rating_config_path</strong> &quot;fastlane/rating_config.json&quot;<br><br><strong>app_review_information</strong>(<br>  first_name: &quot;Pavel&quot;,<br>  last_name: &quot;Vashkel&quot;,<br>  phone_number: &quot;&quot;,<br>  email_address: &quot;your-email-address&quot;,<br>  notes: &quot;Some note for reviewers&quot;<br>)<br><br><strong>name</strong>(<br>  &#39;en-US&#39; =&gt; &quot;CoolApp&quot;,<br>  # ...<br>  &#39;ru&#39; =&gt; &quot;CoolApp&quot;<br>)<br><br><strong>support_url</strong>(<br>  &#39;en-US&#39; =&gt; &quot;http://example.com/&quot;,<br>  # ...<br>  &#39;ru&#39; =&gt; &quot;http://example.com/&quot;<br>)<br><br><strong>keywords</strong>(<br>  &#39;en-US&#39; =&gt; &quot;some, key, word&quot;,<br>  # ...<br>  &#39;ru&#39; =&gt; &quot;some, key, word&quot;<br>)<br><br><strong>app_icon</strong> &#39;./AppIcon.png&#39;<br><strong>platform</strong> &#39;ios&#39;<br><strong>copyright</strong> &quot;2017 datarockets, LLC&quot;<br><br><strong>primary_category</strong> &#39;MZGenre.Games&#39;<br><strong>secondary_category</strong> &#39;MZGenre.Entertainment&#39;<br><strong>primary_first_sub_category</strong> &#39;MZGenre.Card&#39;<br><strong>primary_second_sub_category</strong> &#39;MZGenre.Board&#39;</pre><p>In config file we pointing to <em>rating_config.json</em> file which is used to calculate app rating in iTunes Connect. Every category is scored from 0 to 2.</p><pre>{<br>  <strong>&quot;CARTOON_FANTASY_VIOLENCE&quot;</strong>: 0,<br><strong>  &quot;REALISTIC_VIOLENCE&quot;</strong>: 0,<br><strong>  &quot;PROLONGED_GRAPHIC_SADISTIC_REALISTIC_VIOLENCE&quot;</strong>: 0,<br><strong>  &quot;PROFANITY_CRUDE_HUMOR&quot;</strong>: 0,<br><strong>  &quot;MATURE_SUGGESTIVE&quot;</strong>: 0,<br><strong>  &quot;HORROR&quot;</strong>: 0,<br><strong>  &quot;MEDICAL_TREATMENT_INFO&quot;</strong>: 0,<br><strong>  &quot;ALCOHOL_TOBACCO_DRUGS</strong>&quot;: 0,<br><strong>  &quot;GAMBLING&quot;</strong>: 0,<br><strong>  &quot;SEXUAL_CONTENT_NUDITY&quot;</strong>: 0,<br><strong>  &quot;GRAPHIC_SEXUAL_CONTENT_NUDITY&quot;</strong>: 0,<br><strong>  &quot;UNRESTRICTED_WEB_ACCESS&quot;</strong>: 0,<br><strong>  &quot;GAMBLING_CONTESTS&quot;</strong>: 0<br>}</pre><p>Now run the following command.</p><pre>$ <strong>bundle exec fastlane</strong> deliver</pre><p>This step can take a while. Before submitting, <em>Preview.html</em> file with all app metadata and screenshots will be generated. You can check if everything is filled in correctly.</p><h4>Use it all together</h4><p>Above we used every fastlane tool as separate command. Although this is not the worst option, all this can be automated even further by using one more config file — <strong>Fastfile</strong>. <strong>Fastfile</strong> is a kinda top-level config file where you can define <em>lanes</em> for different tasks.</p><p><strong>Fastfile</strong> could look like this.</p><pre><strong>fastlane_version</strong> &quot;1.109.0&quot;<br><strong>default_platform</strong> :ios<br><strong>platform</strong> :ios do<br><br><strong>  before_all</strong> <strong>do</strong><br>    <strong>cocoapods</strong>(<br>      <strong>clean</strong>: true,<br><strong>      repo_update</strong>: true<br>    )<br>  <strong>end</strong><br><br>  desc &quot;Submit a new build to AppStore&quot;<br>  <strong>lane</strong> :release <strong>do</strong><br><br>    <strong>produce</strong><br>    <strong>match</strong>(<strong>type</strong>: &quot;appstore&quot;)<br>    <strong>gym</strong>(<br><strong>      export_method</strong>: &quot;app-store&quot;,<br><strong>      export_options</strong>: {<br><strong>        provisioningProfiles</strong>: {<br>          &quot;com.datarockets.CoolApp&quot; =&gt; &quot;match AppStore com.datarockets.CoolApp&quot;<br>        }<br>      }<br>    )<br>    <strong>snapshot</strong><br>    <strong>frameit</strong> gold<br>    <strong>deliver</strong><br><br>    desc &quot;Post a message to slack channel&quot;<br>    <strong>slack</strong>(<br>      <strong>message</strong>: &quot;CoolApp was released&quot;,<br><strong>      slack_url</strong>: &quot;https://hooks.slack.com/services/desired-chanel&quot;<br>    )<br><br>    <strong>error</strong> <strong>do</strong> |lane, exception|<br>    <strong>end</strong><br><br>  <strong>end</strong><br><br><strong>end</strong></pre><p>Now instead of bunch of separate commands only one need to be executed.</p><pre>$ <strong>bundle exec fastlane</strong> ios release</pre><h4>Wrapping up</h4><p><strong>Fastlane</strong> is a great tool helping to add more automation to development process and make app development fun again.</p><h4><strong>Links</strong></h4><p>Github page: <a href="https://github.com/fastlane/fastlane">https://github.com/fastlane/fastlane</a><br>Official documentation: <a href="https://docs.fastlane.tools/">https://docs.fastlane.tools</a></p><p>Original post: <a href="https://datarockets.com/blog/ios-release-with-fastlane">https://datarockets.com/blog/ios-release-with-fastlane</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c4796530fea8" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>